Skip to main content

No project description provided

Project description

Django tabbed admin2

Fork of old Django tabbed admin https://github.com/omji/django-tabbed-admin


Install


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

From PyPi

pip install django_tabbed_admin2

From Github

.. code-block:: shell-session

https://github.com/omji/django-tabbed-admin#egg=tabbed_admin

setup

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

.. code-block:: python

INSTALLED_APPS = (
    ...
    'django_tabbed_admin2'
    ...
)

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:

.. code-block:: python

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.

LINKS

Development: https://github.com/4Sigma/django-tabbed-admin

Package:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_tabbed_admin2-0.1.1.tar.gz (63.9 kB view details)

Uploaded Source

Built Distribution

django_tabbed_admin2-0.1.1-py3-none-any.whl (94.6 kB view details)

Uploaded Python 3

File details

Details for the file django_tabbed_admin2-0.1.1.tar.gz.

File metadata

  • Download URL: django_tabbed_admin2-0.1.1.tar.gz
  • Upload date:
  • Size: 63.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for django_tabbed_admin2-0.1.1.tar.gz
Algorithm Hash digest
SHA256 6f56b9056089ab7d1061995cb8fbc33d1c61e132f49a8cabab5a30acdc84bed4
MD5 4d42f604d7e872505914c610fcbbaf26
BLAKE2b-256 a9cbf5f13f35d869350dd128e6c02bf6f5f5112f4a5e61d469cf4b9ef968e9ca

See more details on using hashes here.

File details

Details for the file django_tabbed_admin2-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tabbed_admin2-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b4e407d16c91b2920fb1283c2567f58f99ceec8b77f98ede565c8ebe25692f2d
MD5 1f2cd7206831374817edc3ca7ce2eb00
BLAKE2b-256 992f9abfb33feb847c5f4eb7ca8a2bb8e7c4e07327ae6f38c62c35207a7afee6

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page