Article

Use Django Packages - Don't Reinvent the Wheel

September 07, 2016  |  Pluralsight
Use Django Packages - Don't Reinvent the Wheel
Learn something new. Take control of your career.

You may be wondering why you might need Django packages since Django is known for being a “batteries-included” framework and already includes most of the features you will need. Even so, there are packages that will make your life easier so you don’t have to rewrite code to do somewhat common things that require a bit of heavy lifting, like social authentication or deploying your Django project to Heroku or Python Anywhere. So how do you find these Django packages?

One source we cover in our new Django course, Digging Into Django, is PyPI — the Python Package Index. In general, the Python community is incredibly dedicated to spreading the use of the Python language far and wide through the contribution of open source packages and utilities. The Django community is no exception — if you search for Django on PyPI, you get 11,000+ results! PyPI might be a little overwhelming to weed through, so some better Django-specific resources are djangopackages.org and awesome-django.com. For instance, at djangopackages.orgyou can pull up categories, like authentication, and see rankings of most used and other helpful statistics:

If you go to the Authentication section of awesome-django.com, you will find a smaller curated list of packages based on the editors’ opinions:

Although their usefulness depends on what type of app you’re making, let’s go over some of the packages I’ve used and would recommend. In Digging Into Django, we simply used the built-in user registration and authentication features — we didn’t use any external packages. However, in the follow-up Watch Us Build screencast, we used python-social-auth, which allows you to use a third-party social app like Google, Facebook, or Twitter to share credentials with your app. If you don’t want to use social authentication but still want some help with the registration process, registration redux provides helpful links and templates. If you are interested in building a Django REST API for your app, the Django REST framework is useful. We also covered deploying your app to Heroku in the Watch Us Buid a Team Directory App With Django screencast, where we used the Python packages gunicorn to serve our site and whitenoise to serve our static files. In Digging Into Django, we used Pillow, which is a Python package for image processing not specific to Django that allows using the ImageField in Django models but can do so much more, like editing and saving images in your app.

If you wanted to continue building an Instagram-like app, like the TreasureGram and TravelTracker apps we covered in Try Django and Digging Into Django, the following packages would come in handy:

  • Favorites for favoriting, liking, following, and reporting links
  • Comments XTD for commenting with thread support, follow-up notifications, email confirmation, and like/dislike flags
  • Embed-Video for easily embedding YouTube and Vimeo videos and music from SoundCloud
  • Taggit for simple tagging

Finally, I’ve heard good things about Cookiecutter, which creates projects from project templates, e.g. Python package projects. Some useful cookiecutters are listed at djangopackages.org. For instance, if you wanted to create your own reusable, installable Django package, you might start with the CookieCutter-DjangoPackage. I’ll give it a try and let you know how it goes!

I hope you enjoyed this rundown of useful Django packages and now can see how easily extensible Django is for any and all of your app-building needs. 

Learn something new. Take control of your career.
Pluralsight

Pluralsight

Pluralsight is the technology skills platform. We enable individuals and teams to grow their skills, accelerate their careers and... See more