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_groupsto yourINSTALLED_APPS:INSTALLED_APPS = [ ... "django_admin_groups", ]
Usage
-
Define your custom groups in the
settings.pyfile using theADMIN_GROUPSsetting.Each group includes:
group_name: The name displayed in the admin panel.models: A list of model paths in the formatapp_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:
- Fork the repository.
- Clone your forked repository.
- Create a feature branch.
- Make your changes and add tests (if necessary).
- Submit a pull request.
GitHub repository.
Author: Omar Swailam
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_admin_groups-0.2.tar.gz.
File metadata
- Download URL: django_admin_groups-0.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fefa44f50011c0bfbb2033a7ef4bb4ad14e3fb9d23befd5455dc041935772454
|
|
| MD5 |
e46622e4a96d719df5f94b25b4373ede
|
|
| BLAKE2b-256 |
9dad54a35b7cd7e44d61fffd1e63135049705e2d665b4556abd9453345c040e0
|
File details
Details for the file django_admin_groups-0.2-py3-none-any.whl.
File metadata
- Download URL: django_admin_groups-0.2-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a25d1903de0704b4b58a9e69b01580cf5b33b20e769448a9b386856d7737d88e
|
|
| MD5 |
0a7b609f7c4c9c2355df9fb5a4b150c4
|
|
| BLAKE2b-256 |
c06f4eaa879a00cf73dc84c97910c467c38e1ade7bb49279cb0b300b3df7efa7
|