Sample application to demonstrate django-subadmin
usage.
Checkout code from GitHub
git clone https://github.com/inueni/django-subadmin-example.git
Switch to django-subadmin-example
directory and run the following commands (you should do this in virtualenv
).
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
python manage.py fakedata
python manage.py runserver
Then open django admin (http://127.0.0.1:8000/admin/) in your browser, log-in and explore MailingList
section to see django-subadmin
in action.
SubAdmin
instances are accesible from edit view of the ModelAdmin
instance they are nested in. In the screenshot above you can see links to Subscribers and Messages subadmins (marked with red rectangle) for MailingList
instance Mailing list 5.
SubAdmin
looks and behaves just like a regular ModelAdmin
, but looking at breadcrumbs (marked with red rectangle), you can see it is nested within another ModelAdmin
. Displayed Subscribers
are limited to those related to MailingList
instance Mailing list 5.
When adding or editing objects with SubAdmin
, ForeignKey
fields to parent instances are removed from the form and automatically set when saving. In this example mailing_list
field is removed and value is set to parent MailingList
instance Mailing list 5.