What's inside
- Intro
- But first - is Django a library?
- Modules vs. packages - what are modules in Django?
- The best Django packages
- Extra: What is Django Allauth?
- Summary
- Contact us
- Resources
Initially published: 21st of June 2018 Updated: 6th of December 2022
Intro
Are you starting a Django project soon? You’re probably wondering whether there are any valuable packages out there that could help you with your projects.
In this piece, you’ll find a list of the most valuable Django packages with links and descriptions to help you get them quickly to work without having to do a lot of research beforehand.
All the packages I chose support Python 3 and are in a stable version to help support a wide range of Django projects.
Ready to explore the world of Django packages?
Let's dive in!
But first - is Django a library?
It's easy to get lost in Python tools because many new frameworks and libraries are available in its ecosystem today.
Read more: 10 Best Python Web Frameworks
Still, it's worth clarifying this: Django is not a library but a framework.
Django is a free, open-source, high-level, complete Python web framework that promotes rapid development and clean design. It was developed by a group of experienced programmers who aimed to remove the hassle of developing web apps and allow teams to focus on writing code without having to reinvent the wheel every time. That means writing fewer lines of code!
Thanks to its incredible speed, high security, flexibility, and scalability, Django quickly gained traction and today is one of the most popular technologies for web development projects in Python.
For those taking their first steps in Django, we recommend this article: What is Django and how to get started?
Modules vs. packages - what are modules in Django?
Modules and packages are sometimes confused with one another, so let's take a moment to explain the difference before we move on to our list.
A package refers to a collection of Python modules. A module is a single Python file, while a package is a directory of such modules. A package contains an additional init.py file to distinguish itself from a mere directory that includes some Python scripts.
In this article, you will find 30 Python built-in modules you should be using in your project.
The best Django packages
Note: Since there are several good reasons why coding frontend in Django isn’t the best idea, the following list contains only packages for backend projects.
- sentry-sdk
Description:
- This is a must-have tool for any Django project, as we must stay informed about all the code-based issues in the application.
- Firstly: the package immediately alerts us about all the previously-uncaught exceptions in production.
- Secondly: we can catch the issue ourselves and send the error information to the sentry, adding more relevant data.
- Building an alert system on our own is non-trivial and debugging without this kind of logs is next to impossible.
Solves:
That situation is when the server throws an error, and you don’t have to investigate it.
Awesomeness:
- It will catch any uncaught exceptions (which means 500 returned from the server with no further information usually) and send us full details about the issue right after it happens.
- When the code is working correctly, the sentry is helpful as an alert system to which we can send the errors or logs about non-normal events.
- djangorestframework
Description:
If you want to write a REST Architectural Constraints API, this package will do that for you – together with proper, auto-generated documentation that supports implementing the package in projects.
Solves:
No need to write the REST API yourself.
Awesomeness:
- Creating REST API endpoints for your models will take just a few lines of code.
- Auto-generated documentation is great because it always changes with the endpoints.
You may be interested in this: The Ultimate Django Rest Framework Tutorial
- django-extensions
Description:
- A set of tools that help with your daily work.
- JSONField was introduced in this package before officially becoming part of Django 1.9 (for PostgreSQL, of course).
- V See the awesomeness list below V But keep in mind that this repo solves several other problems. I found them rather boring and uncommon.
Solves:
It adds a bunch of random valuable functionalities.
Awesomeness:
- command shell_plus runs the Django shell with preloaded files, classes, and models that speed up any work with the Django shell.
More fields that include:
- AutoSlugField – generates a unique slug for given data
- CreationDateTimeField and ModificationDateTimeField – stores the first save to the database and the last DateTime modification.
- Job scheduling with Django! You’ll still need some cron, but having scripts in Django makes it easier to administrate.
You might like this: 6 expert tips for building better Django models
- django-rest-framework-jwt
Description:
While using DRF for some projects, adding some JWT token authorization is essential. That’s exactly what this package is about.
Solves:
You won’t have to implement and manage the Authentication token for the API on your own.
Awesomeness:
Provides everything you need for JWT Auth: the login endpoint and Django auth class.
- django-rest-swagger
Description:
The DRF offers auto-generated documentation – and this package makes the documentation nicer for your projects.
Solves:
Creates nice documentation out of the DRF API for free.
Awesomeness:
- Nice auto-documentation for your endpoints.
- It's easy to document custom endpoints manually.
- easy-thumbnails
Description:
Any web service that allows uploading and viewing photos need the thumbnails feature. This package provides it.
Solves:
All servers hosting images need thumbnails, and this package is the solution.
Awesomeness:
Configurable thumbnails filed for Django models that automatically generate a smaller version of the uploaded image.
- django-simple-history
Description:
This package keeps a history of record changes. If a client has access to the database through the admin panel, they might change something by mistake or want to return to the previous text version.
Solves:
Keeps a history of changed rows in the database.
Awesomeness:
Keeps track of all model changes while setup takes no time.
- django-adminactions
Description:
A simple data export to known file types like CSV or XLS. You can also export data as a fixture to the test server, and this fixture can contain Foreign Keys. The package allows generating graphs in the admin panel as well.
Solves:
Adds some functions that come in handy during the early stages of developing an app.
Awesomeness:
Export data from the admin panel to XSL, CSV, and Fixture.
- django-model-utils
Description:
A set of useful utils for Django models.
Solves:
Adds some models and fields that already help with some common issues.
Awesomeness:
MonitorField field is the DateTime field, and it's updated to now() each time the field it’s looking to get updated.
- django-storages
Description:
- Allows using any cloud storage services as the default file storage. That becomes important when you want to pass whatever users send to another storage.
- For example, users may send us substantial data like photos, movies, or backups. To make this data available for them without slowing down the app, it’s a good idea to use cloud storage solutions like Google Cloud.
Solves:
It uses almost any remote storage as the Django default file storage.
Awesomeness:
Allows using s3 or Google storage as default file storage.
- django-filter
Description:
- It uses a two part CalVer versioning scheme (such as
21.1
). - Django-Filter is a mature and stable package.
- It is a generic, reusable application to alleviate writing some of the more mundane bits of view code.
Solves:
It allows users to filter down a queryset based on a model's fields, displaying the form to let them do this.
Awesomeness:
- Django-filter can be used for generating interfaces similar to the Django admin’s
list_filter
interface. - It has an API very similar to Django’s
ModelForms
.
- django-debug-toolbar
Description:
- Configurable set of panels which allows displaying debug information about the current request and response.
- After the click it displays more details about the panel’s content.
Solves:
- Request variables, including GET, POST, cookie, and session information.
- Which templates were rendered the context provided to each template.
Awesomeness:
It can show all SQL queries performed during response creation and processing, including timing and 'EXPLAIN' output for each query in conjunction with the total time spent performing SQL queries. If python-pygments is installed, the SQL syntax is highlighted.
- django-cors-headers
Description:
django-cors-headers is a security oriented package designed to protect users from malicious websites by providing a mechanism to allow only specific domains to perform those cross origin requests.
Solves:
- It adds Cross-Origin Resource Sharing (CORS) headers to responses.
- This allows in-browser requests to the Django application from other origins.
Awesomeness:
It adds another security layer on top of already quite impressive django security feature list.
Extra: What is Django Allauth?
The list above includes the best Django packages available in its rich ecosystem. But one more package should become part of this list as an extra.
django-allauth
This package offers an integrated set of Django applications that address problems like authentication, registration, account management, and third-party account authentication (think social media accounts).
Why did I include it here?
The majority of existing Django apps that tackle the problem of social authentication focus only on that functionality. To support authentication via a local account, developers usually need to integrate another app. By following this approach, local and social authentications become separated, and incorporating them is challenging.
django-allauth
was created to fill this gap, offering users a tool designed to include a fully-integrated authentication app that allows both local and social authentication.
Summary
For many reasons, Python has become an essential programming language for web development projects. One of them is the rich ecosystem of libraries, frameworks, and tools like packages that help software developers accelerate the process of building apps, manage it better and focus on what matters most (like app architecture or translating business logic).
This list of Django packages will help you next time you develop a web app using Python and Django. To learn more about Django packages, look at this helpful site.
Contact us
At Sunscrapers, we have a team of developers and software engineers with outstanding technical knowledge and experience. We can build your project successfully.
Talk with us about hiring Python and Django developers and work with the best. Sunscrapers can help you make the most out of Python, Django, and other technologies to put your project to the next level.
Contact us at hello@sunscrapers.com
Resources
Sunscrapers Guide to the Django REST Framework
Articles mentioned in the post: