django-with-extra-context-admin
Provide a simple way to add extra context for view rendering in Django's admin site.
Install
pip install django-with-extra-context-admin
Usage
Note:
There is NO need to add app name django_with_extra_context_admin into INSTALLED_APPS. Just install this application and import the admin extention DjangoWithExtraContextAdmin where you need.
app/admin.py
from django.contrib import admin
from django_with_extra_context_admin.admin import DjangoWithExtraContextAdmin
from .models import MyModel
class MyModelAdmin(DjangoWithExtraContextAdmin, admin.ModelAdmin):
django_with_extra_context_admin_view_name = False
def get_extra_context(self, request, **kwargs):
extra_context = super().get_extra_context(request, **kwargs) or {}
extra_context.update({
...
"var1": "value1",
"var2": "value2",
...
})
return extra_context
admin.site.register(MyModel, MyModelAdmin)
Where to use?
All admin's default views are inject with the extra context.
- changeform_view
- changelist_view
- delete_view
- history_view
- add_view
- change_view
Any extra context provided?
By default we always add django_with_extra_context_admin_view_name to the extra context. It can be disabled by set add_django_with_extra_context_admin_view_name to False. The value of variable django_with_extra_context_admin_view_name is the the name of current view name, e.g. changeform_view, changelist_view.
Releases
v0.1.0 2020/03/13
- First release.
Metadata
Release files for django-with-extra-context-admin 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| django-with-extra-context-admin-0.1.0.tar.gz | 3.3 kB | Without provenance | Details for django-with-extra-context-admin-0.1.0.tar.gz |
Release files / django-with-extra-context-admin-0.1.0.tar.gz
| Download URL | django-with-extra-context-admin-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dcc52348e11cbb384ce592f5e1b1d118809633c4e9c40b44f93e59a877ab51c3
|
|
BLAKE2b-256 checksum How to use checksums |
26a05678d0d2a47384b4287b107a4b4aa036c338245285ffde359b53b7d19ed0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.8.2
|
Security for django-with-extra-context-admin 0.1.0
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.