Django Tabbed Admin2
This is a fork of the old Django tabbed admin, available at omji/django-tabbed-admin.
Installation
It is strongly recommended to install this theme from Git using PIP in your project's virtual environment.
From PyPi
pip install django_tabbed_admin2
From GitHub
https://github.com/omji/django-tabbed-admin#egg=tabbed_admin
Setup
Simply add the app to your list of installed apps in settings.py.
INSTALLED_APPS = (
...
'django_tabbed_admin2',
...
)
Django-tabbed-admin, by default, requires the Jquery UI tabs plugin to work. It is packaged with the static files required for functionality, but they are not activated by default to avoid conflicts with other libraries.
To activate the Jquery UI statics, add the following line to the project settings:
TABBED_ADMIN_USE_JQUERY_UI = True
Configure Admin Tabs
To add tabs to a model admin, it should inherit from tabbed_admin.TabbedModelAdmin and contain a tabs attribute. The tabs attribute configuration is similar to the fieldsets and inlines setup logic.
A tuple can be created for each tab in the same way as for fieldsets, except that inlines can be added anywhere in between.
tab_overview = (
(None, {
'fields': ('name', 'bio', 'style')
}),
MusicianInline,
('Contact', {
'fields': ('agent', 'phone', 'email')
})
)
Then each tuple has to be passed to a tabs attribute prefixed by the verbose name to display within the tab:
tabs = [
('Overview', tab_overview),
('Albums', tab_album)
]
A full example would be:
from django.contrib import admin
from tabbed_admin import TabbedModelAdmin
from .models import Band, Musician, Album
class MusicianInline(admin.StackedInline):
model = Musician
extra = 1
class AlbumInline(admin.TabularInline):
model = Album
extra = 1
@admin.register(Band)
class BandAdmin(TabbedModelAdmin):
model = Band
tab_overview = (
(None, {
'fields': ('name', 'bio', 'style')
}),
MusicianInline,
('Contact', {
'fields': ('agent', 'phone', 'email')
})
)
tab_album = (
AlbumInline,
)
tabs = [
('Overview', tab_overview),
('Albums', tab_album)
]
Configure Tabs Dynamically
Be warned that the tabs will completely reset the fieldsets and inlines attributes to avoid conflicts during form saving. Both attributes are overwritten with the entries passed to the tabs attribute. For the same reasons, it is highly recommended not to overwrite get_fieldsets or get_inlines.
You can pass and modify the tabs dynamically the same way you would do for fieldsets or inlines.
def get_tabs(self, request, obj=None):
tabs = self.tabs
if obj is not None:
tab_overview = self.tab_overview + ('Social', {
'fields': ('website', 'twitter', 'facebook')
})
tab_ressources = self.tab_ressources + (InterviewInline, )
tabs = [
('Overview', tab_overview),
('Ressources', tab_ressources)
]
self.tabs = tabs
return super(BandAdmin, self).get_tabs(request, obj)
Change the Jquery UI
You can change the Jquery UI CSS and JS by either overriding the media in the admin class:
class Media:
css = {
'all': ('css/jquery-ui.theme.min.css',)
}
or by changing the following settings, TABBED_ADMIN_JQUERY_UI_CSS and TABBED_ADMIN_JQUERY_UI_JS:
TABBED_ADMIN_JQUERY_UI_CSS = 'static/css/my-custom-jquery-ui.css'
TABBED_ADMIN_JQUERY_UI_JS = 'static/js/my-custom-jquery-ui.js'
Contribution
Please feel free to contribute. Any help and advice are much appreciated. You will find an example application to run and develop the library easily.
Links
- Development: https://github.com/4Sigma/django-tabbed-admin
Metadata
Release files for django-tabbed-admin2 2.0.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 | Actions |
|---|---|---|---|---|
| django_tabbed_admin2-2.0.1.tar.gz | 63.7 kB | Without provenance | Details for django_tabbed_admin2-2.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_tabbed_admin2-2.0.1-py3-none-any.whl | Python 3 | none | any | Details for django_tabbed_admin2-2.0.1-py3-none-any.whl |
Total release size: 158.2 kB
Release files / django_tabbed_admin2-2.0.1.tar.gz
| Download URL | django_tabbed_admin2-2.0.1.tar.gz |
|---|---|
| Size | 63.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b03a34f22159e4c6b21fb4f82507b03284f1af35242977bac11fa79764f0fc1e
|
|
BLAKE2b-256 checksum How to use checksums |
c02ec9fd0940a1323c2898fd8f2068a4c01bef2f96df242496d72c97de16d3ed
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / django_tabbed_admin2-2.0.1-py3-none-any.whl
| Download URL | django_tabbed_admin2-2.0.1-py3-none-any.whl |
|---|---|
| Size | 94.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6313cfc4626a5c8c6ab3462cc84ed86a7a22e50996aae07e6bad98fb5ce3214
|
|
BLAKE2b-256 checksum How to use checksums |
db9bdd6d4de88594b25f95c06ed1eac66fb0c991377fc8e0c1e2e7426966a2bc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Security for django-tabbed-admin2 2.0.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.
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.