django-tabbed-admin2


Namedjango-tabbed-admin2 JSON
Version 2.0.1 PyPI version JSON
download
home_page
Summary
upload_time2023-12-27 10:37:19
maintainer
docs_urlNone
author4Sigma
requires_python>=3.8,<4.0
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django Tabbed Admin2

This is a fork of the old Django tabbed admin, available at [omji/django-tabbed-admin](https://github.com/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

```bash
pip install django_tabbed_admin2
```

### From GitHub

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

## Setup

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

```python
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:

```python
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.

```python
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:

```python
tabs = [
    ('Overview', tab_overview),
    ('Albums', tab_album)
]
```

A full example would be:

```python
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`.

```python
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:

```python
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`:

```python
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](https://github.com/4Sigma/django-tabbed-admin)


            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "django-tabbed-admin2",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "",
    "keywords": "",
    "author": "4Sigma",
    "author_email": "devops@4sigma.it",
    "download_url": "https://files.pythonhosted.org/packages/c0/2e/c9fd0940a1323c2898fd8f2068a4c01bef2f96df242496d72c97de16d3ed/django_tabbed_admin2-2.0.1.tar.gz",
    "platform": null,
    "description": "# Django Tabbed Admin2\n\nThis is a fork of the old Django tabbed admin, available at [omji/django-tabbed-admin](https://github.com/omji/django-tabbed-admin).\n\n## Installation\n\nIt is strongly recommended to install this theme from Git using PIP in your project's virtual environment.\n\n### From PyPi\n\n```bash\npip install django_tabbed_admin2\n```\n\n### From GitHub\n\n```shell-session\nhttps://github.com/omji/django-tabbed-admin#egg=tabbed_admin\n```\n\n## Setup\n\nSimply add the app to your list of installed apps in `settings.py`.\n\n```python\nINSTALLED_APPS = (\n    ...\n    'django_tabbed_admin2',\n    ...\n)\n```\n\nDjango-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.\n\nTo activate the Jquery UI statics, add the following line to the project settings:\n\n```python\nTABBED_ADMIN_USE_JQUERY_UI = True\n```\n\n## Configure Admin Tabs\n\nTo 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.\n\nA tuple can be created for each tab in the same way as for `fieldsets`, except that `inlines` can be added anywhere in between.\n\n```python\ntab_overview = (\n    (None, {\n        'fields': ('name', 'bio', 'style')\n    }),\n    MusicianInline,\n    ('Contact', {\n        'fields': ('agent', 'phone', 'email')\n    })\n)\n```\n\nThen each tuple has to be passed to a `tabs` attribute prefixed by the verbose name to display within the tab:\n\n```python\ntabs = [\n    ('Overview', tab_overview),\n    ('Albums', tab_album)\n]\n```\n\nA full example would be:\n\n```python\nfrom django.contrib import admin\nfrom tabbed_admin import TabbedModelAdmin\nfrom .models import Band, Musician, Album\n\nclass MusicianInline(admin.StackedInline):\n    model = Musician\n    extra = 1\n\nclass AlbumInline(admin.TabularInline):\n    model = Album\n    extra = 1\n\n@admin.register(Band)\nclass BandAdmin(TabbedModelAdmin):\n    model = Band\n\n    tab_overview = (\n        (None, {\n            'fields': ('name', 'bio', 'style')\n        }),\n        MusicianInline,\n        ('Contact', {\n            'fields': ('agent', 'phone', 'email')\n        })\n    )\n    tab_album = (\n        AlbumInline,\n    )\n    tabs = [\n        ('Overview', tab_overview),\n        ('Albums', tab_album)\n    ]\n```\n\n## Configure Tabs Dynamically\n\nBe 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`.\n\nYou can pass and modify the tabs dynamically the same way you would do for `fieldsets` or `inlines`.\n\n```python\ndef get_tabs(self, request, obj=None):\n    tabs = self.tabs\n    if obj is not None:\n        tab_overview = self.tab_overview + ('Social', {\n            'fields': ('website', 'twitter', 'facebook')\n        })\n        tab_ressources = self.tab_ressources + (InterviewInline, )\n        tabs = [\n            ('Overview', tab_overview),\n            ('Ressources', tab_ressources)\n        ]\n    self.tabs = tabs\n    return super(BandAdmin, self).get_tabs(request, obj)\n```\n\n## Change the Jquery UI\n\nYou can change the Jquery UI CSS and JS by either overriding the media in the admin class:\n\n```python\nclass Media:\n    css = {\n        'all': ('css/jquery-ui.theme.min.css',)\n    }\n```\n\nor by changing the following settings, `TABBED_ADMIN_JQUERY_UI_CSS` and `TABBED_ADMIN_JQUERY_UI_JS`:\n\n```python\nTABBED_ADMIN_JQUERY_UI_CSS = 'static/css/my-custom-jquery-ui.css'\nTABBED_ADMIN_JQUERY_UI_JS = 'static/js/my-custom-jquery-ui.js'\n```\n\n## Contribution\n\nPlease feel free to contribute. Any help and advice are much appreciated. You will find an example application to run and develop the library easily.\n\n## Links\n\n- Development: [https://github.com/4Sigma/django-tabbed-admin](https://github.com/4Sigma/django-tabbed-admin)\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "",
    "version": "2.0.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "db9bdd6d4de88594b25f95c06ed1eac66fb0c991377fc8e0c1e2e7426966a2bc",
                "md5": "bf0af4d9c2fc2b80c0c9d34229e03a1a",
                "sha256": "e6313cfc4626a5c8c6ab3462cc84ed86a7a22e50996aae07e6bad98fb5ce3214"
            },
            "downloads": -1,
            "filename": "django_tabbed_admin2-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bf0af4d9c2fc2b80c0c9d34229e03a1a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 94509,
            "upload_time": "2023-12-27T10:37:17",
            "upload_time_iso_8601": "2023-12-27T10:37:17.696815Z",
            "url": "https://files.pythonhosted.org/packages/db/9b/dd6d4de88594b25f95c06ed1eac66fb0c991377fc8e0c1e2e7426966a2bc/django_tabbed_admin2-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c02ec9fd0940a1323c2898fd8f2068a4c01bef2f96df242496d72c97de16d3ed",
                "md5": "63922bcc50befb0c90b15f86f83cc3bf",
                "sha256": "b03a34f22159e4c6b21fb4f82507b03284f1af35242977bac11fa79764f0fc1e"
            },
            "downloads": -1,
            "filename": "django_tabbed_admin2-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "63922bcc50befb0c90b15f86f83cc3bf",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 63716,
            "upload_time": "2023-12-27T10:37:19",
            "upload_time_iso_8601": "2023-12-27T10:37:19.483466Z",
            "url": "https://files.pythonhosted.org/packages/c0/2e/c9fd0940a1323c2898fd8f2068a4c01bef2f96df242496d72c97de16d3ed/django_tabbed_admin2-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-27 10:37:19",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "django-tabbed-admin2"
}
        
Elapsed time: 1.25472s