dj-typed-settings
Type checking and IDE autocomplete for Django settings to improve the developer experience.
Installation
uv add dj-typed-settings
OR
pip install dj-typed-settings
Goals
- Stay as close to "normal" Django settings.py usage as possible
- No dependencies outside of the Python standard library
- No runtime performance impact (other than the optional system check)
Features
There are multiple features to help you write better Django settings. They are all optional and opt-in, so you can use as much or as little as you want.
Runtime type checking
Ensures your settings.py values match the expected types (e.g., DEBUG must be bool, TEMPLATES must be list). Also catches typos and invalid keys in complex settings like DATABASES, CACHES, and TEMPLATES.
# settings.py
INSTALLED_APPS = [
...,
"dj_typed_settings", # required for runtime type checking
]
This will run a system check when you run python manage.py runserver or python manage.py check and raise an error if any setting is the incorrect type.
Configuration
You can ignore specific validation errors in your settings.py:
TYPED_SETTINGS_IGNORE_ERRORS = [
"DEBUG", # Ignore type errors for DEBUG
"DATABASES.default.ENGINE", # Ignore specific nested key
]
Autocomplete when editing settings
Provides IDE autocomplete when editing settings.py.
# settings.py
from dj_typed_settings.defaults import * # noqa: F403
DEBUG = True # IDE autocomplete works here when hovering over "DEBUG"
The * import uses default values from Django's global_settings.py (with additional generated types and docstrings) as the base and allows you to override them. This provides the IDE the information needed to give you autocomplete in the editor.
Typed dictionaries
There are a number of complex settings that are normally dictionaries. dj-typed-settings provides helper methods that mimic the structure of the dictionary, but provide a better autocomplete experience.
# settings.py
from dj_typed_settings import DATABASES
DATABASES = {
"default": DATABASE(
ENGINE="django.db.backends.sqlite3",
NAME="db.sqlite3",
)
}
The available methods are:
AUTH_PASSWORD_VALIDATORCACHEDATABASETEMPLATE
Autocomplete when using settings
Provides IDE autocomplete when using settings in other Python code.
# views.py
from dj_typed_settings.conf import settings
def index(request):
if settings.DEBUG: # Autocomplete in the IDE works here
return HttpResponse("debug")
return HttpResponse("production")
This is a drop-in replacement for from django.conf import settings which provides type hints to the IDE for standard Django settings.
For third-party or custom settings, it works exactly like `django.conf.settings`, i.e. provides no additional type hints. However, it will still return the setting as expected.
Automatically cast setting variable types
dj-typed-settings can also automatically fix up setting variable types. This can be helpful when using the standard library os.getenv() which always returns a string.
# .env
DEBUG=True
# settings.py
from os import getenv
from dj_typed_settings import fix_types
DEBUG = getenv("DEBUG") # this would be a string at runtime, i.e. DEBUG = "True"
...
fix_types(globals()) # this will fix up all variables when called at the end of the file
fix_types() converts all default Django setting variables to the expected type when possible. Supported types:
boolfrom"True","true","False","false","1","0"intfrom"123"floatfrom"123.45"listfrom"1,2,3"(comma separated)
Load .env file
dj-typed-settings can parse .env files. It supports shell-style quoting, comments, and line continuations.
The support is not quite as robust as `python-dotenv`, for example it doesn't support nested quotes or environment variable expansion. However, it should work for most common use cases. If your `.env` file is complex, you may want to use `python-dotenv` instead.
from dj_typed_settings import load_env
load_env() # Loads .env into os.environ
load_env() can also take a path to a .env file:
load_env(".env")
load_env() will recursively go up the directory tree until it finds a .env file or a directory with a manage.py file.
Parse database and cache URLs
dj-typed-settings can parse database and cache URLs into the expected setting dictionaries.
from os import getenv
from dj_typed_settings import parse_db_url, parse_cache_url
DATABASES = {
"default": parse_db_url(getenv("DATABASE_URL"))
}
CACHES = {
"default": parse_cache_url(getenv("CACHE_URL"))
}
Acknowledgments
There are a lot of Django settings libraries. Here are a few I use or looked at recently:
- django-configurations
- Dynaconf
- python-decouple
- dj-settings
- django-typed-settings
- django-settings-json
- normalized-django-settings
There are also a lot of libraries which get settings from the environment, which is a slightly different use case, but is related.
Credits
- poethepoet (adapted .env parser)
- django-environ (adapted database/cache URL parser)
Metadata
Release files for dj-typed-settings 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| dj_typed_settings-0.3.1.tar.gz | 117.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dj_typed_settings-0.3.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 149.1 kB
Release files / dj_typed_settings-0.3.1.tar.gz
| Download URL | dj_typed_settings-0.3.1.tar.gz |
|---|---|
| Size | 117.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b96a4f6833e71c5ed1fea4ea91e5ea881a89f60792aa9438d9586396db433bf2
|
|
BLAKE2b-256 checksum How to use checksums |
0da096403fe78736b538a267aa287be8a44121d35c28126b48c3a7062d7a3214
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logRelease files / dj_typed_settings-0.3.1-py3-none-any.whl
| Download URL | dj_typed_settings-0.3.1-py3-none-any.whl |
|---|---|
| Size | 32.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b46775d4dff4c7b6741c397a9f4c90f87985e49e36a4f84fb7b8498737f4aeb2
|
|
BLAKE2b-256 checksum How to use checksums |
fad68d27f339bc07ef0e81cc28d38fc87a37ed179648c869d28b745c57de5d92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logSecurity for dj-typed-settings 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for dj_typed_settings-0.3.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.