Skip to main content

Django tabbed admin

This is a simple fork of django-tabbed-admin https://github.com/omji/django-tabbed-admin with compatibility updates for modern Django versions.

Version 3.2 adds Django 6.1 support while retaining jQuery UI and the existing TABBED_ADMIN_* settings. Tests cover Django 4.2, 5.0, 5.1, 5.2, 6.0 and 6.1. The change-form template now inherits Django’s form controls, actions and popup fields instead of copying them. Projects overriding tabbed_admin/change_form.html must update their override to use this fix. For integration with another admin extension, TabbedModelAdmin.tabbed_admin_base_template can specify a parent template instead of admin/change_form.html. The tabbed_admin_base_template context variable takes precedence over this attribute, allowing other admin extensions to supply the parent template.

Simple library to easilly add tabs to admin forms. It also allows users to re-order inlines and fieldsets. Django tabbed admin is compatible with django-grappelli and django-gipsy.

Install

It is strongly recommanded to install this theme from GIT with PIP onto you project virtualenv.

From PyPi

pip install django-tabbed-admin3

From Github

https://github.com/mgaller/django-tabbed-admin3#egg=tabbed_admin

setup

Simply add the app in your installed apps list in settings.py

INSTALLED_APPS = (
    ...
    'tabbed_admin'
    ...
)

Django-tabbed-admin by default requires Jquery UI tabs plugin in order to work. It is packaged with the static files required to make it funcitonnal, however, they are not activated by default to avoid a conflict with other libraries.

In order to activate the Jquery UI statics, add the following line to the project settings:

TABBED_ADMIN_USE_JQUERY_UI = True

Configure admin tabs

In order to add tabs to a model admin, it should inherit from tabbed_admin.TabbedModelAdmin and contain a tabs attribute. The tab attribute configuration tries to remain similar to the fieldsets and inlines setup logic.

Basically, a tuple can be created for each tab exactely 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 have 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 give:

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 in order to avoid conflicts during the form saving. Both attributes are overwritten with the entries passed to the tabs attribute. For the same reasons, it is highly recommanded 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 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 advices are much appreciated. You will find an example application to run and develop the library easily.

Run the standalone test suite with PYTHONPATH=. python tabbed_admin/tests/runtests.py.

Metadata

Release files for django-tabbed-admin3 3.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-tabbed-admin3 3.2.0
File Size Uploaded Provenance Actions
django_tabbed_admin3-3.2.0.tar.gz 64.8 kB Without provenance Details for django_tabbed_admin3-3.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-tabbed-admin3 3.2.0
File Interpreter ABI Platform Actions
django_tabbed_admin3-3.2.0-py3-none-any.whl Python 3 none any Details for django_tabbed_admin3-3.2.0-py3-none-any.whl

Total release size: 159.8 kB

Release files / django_tabbed_admin3-3.2.0.tar.gz

Download URL django_tabbed_admin3-3.2.0.tar.gz
Size 64.8 kB
Tags Source
SHA-256 checksum
How to use checksums
86bf51c8fb9c4b5aac3354ef576144ca7fd4b7dc48b3e8464615f2fe64b687c4
BLAKE2b-256 checksum
How to use checksums
461dd3522f67d7f834bb398aa2dfae4b686cc0b24ac815b2237a39aeaeec46a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / django_tabbed_admin3-3.2.0-py3-none-any.whl

Download URL django_tabbed_admin3-3.2.0-py3-none-any.whl
Size 95.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1465c84828d82039bf70c39a71c5eb3b1f39a1c6626a0c57e915e35800f98b8d
BLAKE2b-256 checksum
How to use checksums
87165774eae42dab9acf051da3b6d85a9c040bac2641a75e9208f413b3c30b2a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for django-tabbed-admin3 3.2.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page