Descope Django App
Descope is a user management and authentication platform. This plugin integrates Descope with your Django app.
Quick start
- Sign up for Descope and set admin roles
- Get your project id
- Create two roles in Descope, that will be mapped to Django permissions
- is_staff
- is_superuser
Map these roles to any user you would like to make a staff or superuser in your Django app. The names of these roles can be customized in the settings below.
- Install "django-descope" and add to your INSTALLED_APPS setting like this:
uv add django-descope
OR
pip install django-descope
INSTALLED_APPS = [
...
'django_descope',
]
- Add Descope Middleware after the AuthenticationMiddleware and SessionMiddleware
MIDDLEWARE = [
...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
...
'django_descope.middleware.DescopeMiddleware',
]
- Include descope URLconf in your project urls.py like this:
path('auth/', include('django_descope.urls')),
- In your site templates, insert the
descope_flowtag where you want to place your flow
{% load descope %}
<!-- load the descope registry -->
{% if user.is_authenticated %}
<h1>Welcome {{ user.email }} you are logged in!</h1>
<p><a href="{% url 'logout' %}">Log Out</a></p>
{% else %} {% descope_flow "sign-up-or-in" "/" %}
<!-- provide the descope flow id, and where to redirect after a successful login-->
{% endif %}
- Start the development server and visit the newly created view
Testing
See test_admin.py for a rudimentary example of
how to utilize Descope Test Users
when testing your application with authenticated users.
You can use the helper django_descope.authentication.add_tokens_to_request to add the tokens to the django session
Local development
uv sync
uv run ruff check .
uv run python manage.py test
Set DESCOPE_PROJECT_ID and DESCOPE_MANAGEMENT_KEY before running tests that create Descope test users.
Settings
The following settings are available to configure in your project settings.py
Required
DESCOPE_PROJECT_ID
Optional
DESCOPE_MANAGEMENT_KEY
DESCOPE_IS_STAFF_ROLE
DESCOPE_IS_SUPERUSER_ROLE
Metadata
Release files for django_descope 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_descope-3.0.0.tar.gz | 8.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_descope-3.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.4 kB
Release files / django_descope-3.0.0.tar.gz
| Download URL | django_descope-3.0.0.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
cfd27d917ff133eceb69bce9cb9bd15213d5df19277116a93fe6ea9c14e9444b
|
|
BLAKE2b-256 checksum How to use checksums |
7bf525cde1519a645de3aeecc96cfbdf3779085cb60550d7bfff0a9317c74337
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / django_descope-3.0.0-py3-none-any.whl
| Download URL | django_descope-3.0.0-py3-none-any.whl |
|---|---|
| Size | 12.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
330a08d9ef2f83c66f7f7b9435b8158ea05698e982941dc14aa9275174e7358a
|
|
BLAKE2b-256 checksum How to use checksums |
314ca64e6c1a73e8c5079c3b2b57d417ce081ba7178c8a1e51df88b977766c6b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|