My Go-To Libraries/Tools for Django Application

Anozie Baron Chibuikem
3 min readSep 25, 2021

Hi guys, in this article I want to share with you some libraries I usually use for my Django projects.
These libraries are currently what I have discovered are necessary for my day-to-day development process and help me to have consistency across my codebase and team.
Please remember to leave a clap if you find this article helpful.

MyPy
https://mypy.readthedocs.io/en/stable/getting_started.html
If you’ve heard of strongly types languages like Golang, c#, etc, one good thing I like about them is they ensure you declare the types of your variables/return values of a function, etc as you are defining them, Typescript basically replicates the same thing in JavaScript. For the python community, the closest thing we have to that is typing or MyPy(
a static type checker for Python 3 and Python 2.7), although it does not enforce the types declaration since your code will still run without them, MyPy will raise red flags if any, in your codebase based on your configuration thereby helping you reduce the number of errors/bugs that would otherwise have been all over your code.

Black and Isort
https://black.readthedocs.io/en/stable/getting_started.html
https://github.com/PyCQA/isort
Black popularly called ‘the uncompromising code formatter’ helps you organize/format your code in the way you want. Eg, you can set the maximum line length you want and when you run black, it ensures your codebase maintains the set line across all files.
Isort just as the name implies will help you sort your imports
alphabetically, and automatically separated into sections and by type and the good thing is you can set it up to work with Black.
With black and isort properly configured on your codebase, you are guaranteed that your codebase will be properly formatted and imports properly sorted.

Bandit
https://bandit.readthedocs.io/en/latest/
Bandit is a tool designed to find common security issues in Python code. This library has become one of my must-haves in any Django project I’m working on. It detects security issues you might have in your codebase which you might not even be aware of, eg exposing your passwords, unhashed password, etc.

Prospector
http://prospector.landscape.io/en/master/
Prospector is a tool to analyze Python code and output information about errors, potential problems, convention violations, and complexity. It’s another must-have in my project setup. Often you might not even be aware that you have redundant code snippets or that you are breaking several python conventions, this library will help point it out to you.

Other libraries you definitely will find useful include

Pytest
Celery
Redis
Postgres
Anymail
Sentry
Docker
Elasticsearch

One good thing about all these libraries above is that they are mostly flexible enough and you can customize them to suit your need.
They really are awesome and will help you and your team maintain consistency all through your development process and reduce the number of bugs you will need to deal with.

When do I run them?
I run them locally on my development system before I push my code to GitHub/GitLab to ensure they all pass the various checks that I have set up and also usually have a CI/CD pipeline setup that will automatically run them before any new branch can be merged to master.

Thanks for reading.

--

--

Anozie Baron Chibuikem

A backend engineer constantly building a shit ton of things with python and javascript and occasionally writes on technical topics.