django-theme
Allow a Django user to set a theme preference.
Quickstart
-
Install django-theme via pip:
pip install django-theme -
Add
themeto yourINSTALLED_APPSin your project settings.py file:INSTALLED_APPS = [ '...', 'theme', ]
-
Run migrate:
python manage.py migrate -
Add the following to your
context_processorssetting:TEMPLATES = [ { 'BACKEND': '...', 'OPTIONS': { 'context_processors': [ '...', '...', 'theme.context_processors.theme', ], }, }, ]
-
In your template, you can then use the following snippet (theme options are 'system', 'dark' and 'light'):
<body class="{% spaceless %} {% if theme == 'dark' %} dark-theme {% endif %} {% endspaceless %}"> -
The
Thememodel defines a one-to-one relationship with theUsermodel. Therefore, the theme object for a user can be retrieved by using:theme = user.theme
Compatibility
- Compatible with Python 3.8 and above.
- Compatible with Django 3.2 and above.
Versioning
This project follows semantic versioning (SemVer).
License and code of conduct
Check the root of the repo for these files.
Metadata
Release files for django-theme 0.3
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 | Actions |
|---|---|---|---|---|
| django-theme-0.3.tar.gz | 15.9 kB | Without provenance | Details for django-theme-0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_theme-0.3-py3-none-any.whl | Python 3 | none | any | Details for django_theme-0.3-py3-none-any.whl |
Total release size: 33.2 kB
Release files / django-theme-0.3.tar.gz
| Download URL | django-theme-0.3.tar.gz |
|---|---|
| Size | 15.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bc380062f4b876c26e71c4433797877de36814473f896991a01fa3d22095c92
|
|
BLAKE2b-256 checksum How to use checksums |
aa9e64def074dedf7a9012b9ecba5a6f253d61d605e3cb5f439f136a342527c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
|
Release files / django_theme-0.3-py3-none-any.whl
| Download URL | django_theme-0.3-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bf7856327c9585f2b71c48087194371294806f150c9fce8c2736934c819bae8b
|
|
BLAKE2b-256 checksum How to use checksums |
3a9734fbe23e13830b33fe06431d702dc50940c6e103b61c6c5dde9be2225544
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.2 importlib_metadata/4.6.4 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.10
|
Security for django-theme 0.3
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.