20 Django Packages That I Use in Every Project
Tags: django, python, webdev, beginners
Published: 2024-02-09 16:54:00

Django is a "batteries-included" web framework that provides most of your needs to build complex web applications. But its real strength lies in the larger Django ecosystem of third-party packages that go above and beyond what's offered in "core" to provide additional functionality.

There are thousands of third-party packages at this point, and if you are new to Django, it can be overwhelming to make sense of it all. The [Django Packages](https://djangopackages.org/) website is a good resource for discovering new tools, and [Awesome Django](https://awesomedjango.org/) provides a more curated list.

This article highlights my personal favorites that I reach for in almost every new Django project. They saved me a ton of time, and I hope the list does the same for you.

## [Django REST Framework](https://github.com/encode/django-rest-framework)
With `Django REST Framework (DRF)` you can transform an existing Django site into a REST API with very little code. It purposefully mimics many Django conventions and provides robust serialization so you can format your data as you choose. A large community actively maintains the package, with its ecosystem of related third-party packages. 

If forced to pick only one third-party package, most Django developers would select DRF. It is that important. In recent years, [django-ninja](https://github.com/vitalik/django-ninja) has emerged as a competing approach that is performant and async-ready but requires type hints.

## [django-debug-toolbar](https://github.com/jazzband/django-debug-toolbar)
Django does ship with a `Debug` mode, but `django-debug-toolbar` takes it to the next level, providing a configurable set of panels to inspect all areas of a website, including SQL queries, requests and responses, and general performance insights. This package has been around since the beginning of Django and is a mainstay of modern Django development.

## [django-allauth](https://github.com/pennersr/django-allauth)
Django's built-in authentication system is powerful, but `django-allauth`` takes it to another level. It adds many improvements to Django's registration defaults, including social authentication, email-only login, and more. I use it in every Django project.

## [django-extensions](https://github.com/django-extensions/django-extensions)
This package is a Swiss Army watch of valuable additions to Django. There is a [long list of command extensions](https://django-extensions.readthedocs.io/en/latest/command_extensions.html) available, but particular favorites are `shell_plus` for autoloading database models in the Python shell and `runserver_plus` for an improved local web server powered by Werkzeug.

## [django-cors-headers](https://github.com/adamchainz/django-cors-headers)
If you are building an API with Django, you'll need a way to add Cross-Origin Resource Sharing (CORS) headers to responses. This package handles that issue seamlessly and elegantly.

## [environs](https://github.com/sloria/environs)
Environment variables are a necessary part of modern web development, allowing developers to keep private information such as your `SECRET_KEY`, API keys, database credentials, payment info, and more private.

I prefer `environs` and specifically its [usage with Django](https://github.com/sloria/environs?tab=readme-ov-file#usage-with-django), but other popular options in the community include [django-environ](https://github.com/joke2k/django-environ) and [python-dotenv](https://github.com/theskumar/python-dotenv).

## [django-anymail](https://github.com/anymail/django-anymail)
Sending emails can be tricky, but it is a core part of any user registration process or notifications. This package makes it almost easy by seamlessly integrating with the most popular email service providers, including Amazon SES, MailGun, SendGrid, and more.

## [django-filter](https://github.com/carltongibson/django-filter)
An improved way to filter Django QuerySets based on user selections. It also has robust support for adding filters to Django REST Framework.

## [django-storages](https://github.com/jschneier/django-storages)
Are you handling user-uploaded content, commonly called "media, " in Django? Or use a dedicated CDN like S3 for your static files? `django-storages` has you covered with support for multiple storage providers, including Amazon S3, Azure Storage, Digital Ocean, Google Cloud Storage, [and more](https://django-storages.readthedocs.io/en/latest/).

## [Pillow](https://github.com/python-pillow/Pillow)
If you are working with images--user profile pics, image uploads, thumbnails, etc--then you'll likely need to add Pillow, which works alongside Django's [ImageField](https://docs.djangoproject.com/en/5.0/ref/models/fields/#imagefield).

## [django-crispy-forms](https://github.com/django-crispy-forms/django-crispy-forms) 
controls the rendering behavior of your Django forms in an elegant and DRY (Don't Repeat Yourself) way. It also comes with [template packs](https://django-crispy-forms.readthedocs.io/en/latest/install.html#template-packs) for popular CSS frameworks like Tailwind, Bootstrap, Bulma, Foundation, and Uni-form.

## [django-q2](https://github.com/django-q2/django-q2)
Task queues manage background tasks that are time-consuming or resource-intensive, such as sending emails, processing data, long-running tasks, and so on.

Although [Celery](https://github.com/celery/celery) is a popular option, I prefer `django-q2` given it is simpler, more tightly integrated with Django, and uses the Django ORM for scheduling tasks and storing results.

## [Wagtail CMS](https://github.com/wagtail/wagtail)
Wagtail is an excellent choice if you want a customizable content management system (CMS) built in Python. Maintained by the development team at [Torchbox](https://torchbox.com/), Wagtail has its own ecosystem of [third-party packages](https://wagtail.org/packages/), conferences and a large community providing new features and releases.

## [pytest-django](https://github.com/pytest-dev/pytest-django)
Although Django comes with built-in testing tools, [pytest](https://github.com/pytest-dev/pytest) and specifically the [pytest-django](https://github.com/pytest-dev/pytest-django) plugin are widely used in the community.

## [pytest-cov](https://github.com/pytest-dev/pytest-cov)
[Coverage](https://github.com/nedbat/coveragepy) is the widely used tool for measuring code coverage in a project, and the `pytest-cov` plugin integrates seamlessly with `pytest`.

## [model-bakery](https://github.com/model-bakers/model_bakery)
Model Bakery offers a smart way to create fixtures for testing in Django. You can create many objects with a single line of code, saving tons and tons of developer time.

## [whitenoise](https://github.com/evansd/whitenoise)
Websites need a way to serve static files, and in the Python ecosystem, the default choice is WhiteNoise. With a couple of lines of configuration, WhiteNoise transforms your static files into a self-contained unit that can be deployed anywhere without relying on nginx, Amazon S3, or any other external service. 

## [gunicorn](https://github.com/benoitc/gunicorn)
`gunicorn` is one of the most popular WSGI-based servers for Python that is straightforward to use and get going but has enough configuration options to tweak things when necessary. It is simple enough to configure in a few minutes but powerful enough to be used by Instagram, even when they could have chosen other WSGI options like `uwsgi` or `Apache/mod_wsgi`.

## [psycopg](https://github.com/psycopg/psycopg)
If you are working with a PostgreSQL database--and many Django developers do--then `psycopg` is the database adapter you need for production. `psycopg` was recently updated to version 3.0 and is faster than ever.

## [Black](https://github.com/psf/black)
Black is a Python code formatter that is more or less the default in the Django community. Integrating it into your workflow will save time and produce more readable code for you and your colleagues.

## Conclusion
I reach for these twenty third-party packages in almost every new project, but there are many more to explore. If you want to read more, check out the active discussion on the [official Django forum](https://forum.djangoproject.com/t/top-5-3rd-party-packages/391).