Django Framework - Popular extensions, a short-list
Tags: django, python, opensource
Published: 2020-01-17 18:01:56

---
title: Django Framework - Popular extensions, a short-list
published: true
description: A short-list with popular Django modules and apps that might help programmers to code faster new features by reusing open-source work.  
tags: django, python, opensource
canonical_url: https://blog.appseed.us/django-framework-popular-extensions/
cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/7/75/Django_logo.svg/1200px-Django_logo.svg.png
---

Hello Coders, 

This article presents a short-list with popular [Django](https://www.djangoproject.com/) modules and apps that might help Python programmers to code faster new features by reusing some valuable work provided by open-source enthusiasts. 

---

> Thank you! **Content provided by [AppSeed - App Generator](https://appseed.us)**.

---

The list is built based on my personal experience and suggestions published by developers across relevant communities: [Dev.to Pythoners](https://dev.to/t/python) / [Django](https://dev.to/t/django), [Reddit Django](https://www.reddit.com/r/django/) and [Python](https://www.reddit.com/r/Python/) channels, and the classic [Python Forum](https://python-forum.io/).

---

## What is [Django](https://www.djangoproject.com/) (web framework)

Short-Note for beginners - Django is an open-source web application framework written in Python. A framework means a collection of modules and helpers that make development easier. They are logically grouped together and allow you to create web applications by reusing stuff, instead of writing all from scratch.

Useful Django Resources:

- [Django](https://www.djangoproject.com/) - official website and [docs](https://docs.djangoproject.com/)
- [Django](https://www.fullstackpython.com/django.html) - related content provided by the (popular) Full-Stack-Python platform

---

### The Short-List

- [Django Extensions](https://github.com/django-extensions/django-extensions) - a collection of custom extensions
- [Django REST framework](https://www.django-rest-framework.org/) - a flexible toolkit for building Web APIs
- [Drf-Yasg](https://github.com/axnsan12/drf-yasg) - Swagger Docs Generator for Django REST Framework
- [Django Debug Toolbar](https://github.com/jazzband/django-debug-toolbar) - display various debug information for the current request
- [Django CORS Headers](https://github.com/adamchainz/django-cors-headers#django-cors-headers) - adds Cross-Origin Resource Sharing (CORS) headers to responses
- [Django reCaptcha v3](https://github.com/kbytesys/django-recaptcha3) - the integration of [Google reCaptcha v3](https://developers.google.com/recaptcha/intro) in Django
- [Django-environ](https://github.com/joke2k/django-environ) - allows configuring Django apps with environment variables with ease
- [Redis cache](https://github.com/niwinz/django-redis) - Full-featured Redis cache backend for Django.
- [Django Storages](https://django-storages.readthedocs.io/en/latest/) - a collection of custom storage backends for Django: Amazon S3, Azure, Digital Ocean, Dropbox.
- [Django Allauth](https://github.com/pennersr/django-allauth) - Integrated set of Django apps addressing authentication, registration, account management as well as 3rd party (social) account authentication.

---

In case you want to test quickly any extension presented here, by updating some open-source projects, here is a shortlist with [Django free applications](https://github.com/app-generator/django-admin-dashboards)

- [Django Atlantis Dark](https://github.com/app-generator/django-dashboard-atlantis-dark) - source code, MIT license
- [Django Light Blue](https://github.com/app-generator/django-dashboard-light-blue) - source code, MIT license
- [Django Dashboard Black](https://github.com/app-generator/django-dashboard-black) - source code, MIT license
- [Django Dashboard Shards](https://github.com/app-generator/django-dashboard-shards) - source code, MIT license
- [Django Dashboard Material](https://github.com/app-generator/django-dashboard-material) - source code, MIT license

![Django Atlantis Dark - Open-Source Admin Panel coded in Django.](https://raw.githubusercontent.com/app-generator/static/master/products/django-dashboard-atlantis-dark-screen.png)

---

## [Django Extensions](https://github.com/django-extensions/django-extensions)

This is an open-source collection of custom extensions used for Django projects, released under the MIT license.

**How to use it**

```bash
$ pip install django-extensions
```

Enable the extensions in Django configuration (*settings.py*):

```python
INSTALLED_APPS = (
    ...
    'django_extensions',
    ...
)
```

Now we can use the magic via *manage.py* master script:

```bash
$ # Generate (and view) a graphviz graph of app models:
$ python manage.py graph_models -a -o myapp_models.png
$
$ # Check templates for rendering errors:
$ python manage.py validate_templates
$
$ # Run the enhanced django shell:
$ python manage.py shell_plus
```  

---

## [Django REST framework](https://www.django-rest-framework.org/)

Django REST framework is a powerful and flexible toolkit for building Web APIs with an impressive feature set:

- The Web browsable API is a huge usability win for your developers.
- Authentication policies including packages for OAuth1a and OAuth2.
- Serialization that supports both ORM and non-ORM data sources.


**Django REST Links**:

- [Homepage](https://www.django-rest-framework.org/) and [quickstart](https://www.django-rest-framework.org/#quickstart) docs
- [Starter Sample Tutorial](https://www.django-rest-framework.org/#example)

---

## [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/en/latest/)

The Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.

![Django Debug Toolbar - Sample Screen.](https://raw.githubusercontent.com/app-generator/static/master/blog/django-extension-debug-toolbar.png)

---

## [Django CORS Headers](https://github.com/adamchainz/django-cors-headers#django-cors-headers)

A Django App that adds Cross-Origin Resource Sharing (CORS) headers to responses. This allows in-browser requests to your Django application from other origins.

**How to use it**

```bash
$ pip install django-cors-headers
```

Add the extension in Django configuration:

```python

INSTALLED_APPS = [
    ...
    'corsheaders',
    ...
]
```

You will also need to add a middleware class to listen in on responses:

```python

MIDDLEWARE = [  # Or MIDDLEWARE_CLASSES on Django < 1.10
    ...
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    ...
]

```

---

## [Django reCaptcha v3](https://github.com/kbytesys/django-recaptcha3)

This integration app implements a ReCaptcha field for [Google reCaptcha v3](https://developers.google.com/recaptcha/intro).

**How to use it**

```bash
$ pip install django-recaptcha3
```

Then add django-recaptcha3 to your installed apps:

```python
INSTALLED_APPS = (
    ...
    'snowpenguin.django.recaptcha3',
    ...
)
```

Update `settings.py` with reCaptcha private and public key:

```python
RECAPTCHA_PRIVATE_KEY = 'Super_s3Cret_1234'
RECAPTCHA_PUBLIC_KEY  = 'Public key'
```

**Usage in Forms**

```python

from snowpenguin.django.recaptcha3.fields import ReCaptchaField

class ExampleForm(forms.Form):
    [...]
    captcha = ReCaptchaField()
    [...]
```

---

## [Drf-Yasg](https://github.com/axnsan12/drf-yasg)

Swagger/OpenAPI Documentation Generator for Django REST Framework.


**How to use it**

```bash
$ pip install -U drf-yasg
```

Update the `settings.py` to enable the app:

```python
INSTALLED_APPS = [
    ...
    'drf_yasg',
    ...
]
```

Update `urls.py`:

```bash
...
from rest_framework import permissions
from drf_yasg.views import get_schema_view
from drf_yasg import openapi

...

schema_view = get_schema_view(
   openapi.Info(
      title="Snippets API",
      default_version='v1',
      description="Test description",
      terms_of_service="https://www.google.com/policies/terms/",
      contact=openapi.Contact(email="contact@snippets.local"),
      license=openapi.License(name="BSD License"),
   ),
   public=True,
   permission_classes=(permissions.AllowAny,),
)

urlpatterns = [
   url(r'^swagger(?P<format>\.json|\.yaml)$', schema_view.without_ui(cache_timeout=0), name='schema-json'),
   url(r'^swagger/$', schema_view.with_ui('swagger', cache_timeout=0), name='schema-swagger-ui'),
   url(r'^redoc/$', schema_view.with_ui('redoc', cache_timeout=0), name='schema-redoc'),
   ...
]
```

These simple settings will expose 4 endpoints:

- A JSON view of your API specification at /swagger.json
- A YAML view of your API specification at /swagger.yaml
- A swagger-ui view of your API specification at /swagger/
- A ReDoc view of your API specification at /redoc/


---

## [Django-environ](https://github.com/joke2k/django-environ)

Django-environ allows you to use [Twelve-factor methodology](http://www.12factor.net/) to configure your Django application with environment variables.

**How to use it**

```bash
$ pip install django-environ
```

Create an `.env` file in the root of your Django project (sample below):


```txt
DEBUG=on
SECRET_KEY=your-secret-key
DATABASE_URL=psql://urser:un-githubbedpassword@127.0.0.1:8458/database
SQLITE_URL=sqlite:///my-local-sqlite.db
```

**Usage in Django Application** (No need to add it to INSTALLED_APPS)

```python

import environ
env = environ.Env(
    # set casting, default value
    DEBUG=(bool, False)
)
# reading .env file
environ.Env.read_env()

# False if not in os.environ
DEBUG = env('DEBUG')

# Raises django's ImproperlyConfigured exception if SECRET_KEY not in os.environ
SECRET_KEY = env('SECRET_KEY')

# Parse database connection url strings like psql://user:pass@127.0.0.1:8458/db
DATABASES = {
    # read os.environ['DATABASE_URL'] and raises ImproperlyConfigured exception if not found
    'default': env.db(),
    # read os.environ['SQLITE_URL']
    'extra': env.db('SQLITE_URL', default='sqlite:////tmp/my-tmp-sqlite.db')
}
```

--- 

> Thank you!