Skip to main content

Combine models from different apps under custom groups in the Django Admin.

Project description

Django Admin Groups

Combine models from different apps under a single label in the admin panel.

Installation

  • Install the package using pip:

    pip install django-admin-groups
    
  • Add django_admin_groups to your INSTALLED_APPS:

    INSTALLED_APPS = [
        ...
        "django_admin_groups",
        ]
    

Usage

  • Define your custom groups in the settings.py file using the ADMIN_GROUPS setting.

    Each group includes:

    • group_name: The name displayed in the admin panel.
    • models: A list of model paths in the format app_label.ModelName.

    Example:

    ADMIN_GROUPS = [
        {
            "group_name": "group_1",
            "models": [
                "app_1.model1",
                "app_2.model2",
            ],
        },
        {
            "group_name": "group_2",
            "models": [
                "app_1.model3",
                "app_2.model4",
            ],
        },
    ]
    
  • Use the custom admin site provided by the package in your admin.py:

    from django_admin_groups.admin import CustomAdminSite
    from app_1.models import model_1, model_2
    from app_2.models import model_3, model_4
    
    
    custom_admin_site = CustomAdminSite()
    custom_admin_site.register(model_1)
    custom_admin_site.register(model_2)
    custom_admin_site.register(model_3)
    custom_admin_site.register(model_4)
    
  • Route your admin URLs to use the custom admin site in urls.py:

    from django.urls import path from django_admin_groups.admin import custom_admin_site
    
    
    urlpatterns = [
        path("admin/", custom_admin_site.urls),  # Use the custom admin site
    ]
    

How It Works

The package overrides the get_app_list method of the Django admin site to dynamically create custom groups based on your ADMIN_GROUPS configuration. Models retain their default functionality while appearing organized under user-defined labels.


License

This project is licensed under the MIT License. See the LICENSE file for details.


Contribution

We welcome contributions! If you have ideas, suggestions, or bug reports, please open an issue or submit a pull request.

Steps to Contribute:

  1. Fork the repository.
  2. Clone your forked repository.
  3. Create a feature branch.
  4. Make your changes and add tests (if necessary).
  5. Submit a pull request.

GitHub repository.

Author: Omar Swailam

Download files

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

Source Distribution

django_admin_groups-0.3.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_admin_groups-0.3.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file django_admin_groups-0.3.1.tar.gz.

File metadata

  • Download URL: django_admin_groups-0.3.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for django_admin_groups-0.3.1.tar.gz
Algorithm Hash digest
SHA256 bb127689f8b12e89d46f9d3befea75e7f1320ede7bf1221b6bae1d149c800aa1
MD5 e6ddbdad6f5e7f7abb860e96b0c1a95c
BLAKE2b-256 df7a4e19cfb87512c713f395c0fdf8bf8e9a4ff475cf958818e57d11bca3a4ab

See more details on using hashes here.

File details

Details for the file django_admin_groups-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_groups-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a76dd20d86a9ad0aaf2d3a07d1b4dc9e1b1fa94886891671e3712b0b1bdae395
MD5 6723331748ccaf79eacf35109829fb0c
BLAKE2b-256 af5ec3b15a99c78f8d027a8fb93c6fd8c4f6ca73e198d0b8bdf56e516976d5e8

See more details on using hashes here.

Supported by

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