{ "info": { "author": "Mitja Pagon", "author_email": "mitja@inueni.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 1.10", "Framework :: Django :: 1.11", "Framework :: Django :: 1.9", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# django-subadmin\n\n`django-subadmin` provides a special kind of `ModelAdmin`, called `SubAdmin`, that allows it to be nested within another `ModelAdmin` instance. Similar to django's built-in `InlineModelAdmin`, it allows editing of related objects, but instead of doing it inline, it gives you a full `ModelAdmin` as sub-admin of parent `ModelAdmin`. Like `InlineModelAdmin` it works on models related by `ForeignKey`. Multiple `SubAdmin` instances can be nested within a single `ModelAdmin` or `SubAdmin` allowing for multi-level nesting.\n\n## Installation\n\nThe easiest and recommended way to install `django-subadmin` is from [PyPI](https://pypi.python.org/pypi/django-subadmin)\n\n```\npip install django-subadmin\n```\n\nYou need to add `subadmin` to `INSTALLED_APPS` in your projects `settings.py`, otherwise `django` will not be able to find the necessary templates and template tags.\n\n```\n# settings.py\n\nINSTALLED_APPS = (\n ...\n 'subadmin',\n ...\n)\n```\n\n## Example Usage\n\nSometimes things are best explained by an example. Let's say you have two related models.\n\n```python\n# models.py\n\nclass MailingList(models.Model):\n name = models.CharField(max_length=100)\n\n\nclass Subscriber(models.Model):\n mailing_list = models.ForeignKey(MailingList)\n username = models.CharField(max_length=100)\n```\n\nIf you wish to display only subscribers belonging to a particular mailing list in django admin, your only options is to use `InlineModelAdmin`, which is not very practical when dealing with large number of related objects, plus, you loose all the cool functionality of `ModelAdmin` like searching, filtering, pagination, etc ...\n\nThis is where `SubAdmin` comes in.\n\n```python\n# admin.py\n\nfrom subadmin import SubAdmin, RootSubAdmin\nfrom .models import MailingList, Subscriber\n\n# Instead of admin.ModelAdmin we subclass SubAdmin,\n# we also set model attribute\n\nclass SubscriberSubAdmin(SubAdmin): \n model = Subscriber\n list_display = ('username',)\n\n\n# Since this is the top level model admin, which will be registred with admin.site,\n# we subclass RootSubAdmin and set subadmins attribute\n\nclass MailingListAdmin(RootSubAdmin):\n list_display = ('name',)\n\n subadmins = [SubscriberSubAdmin]\n \n\nadmin.site.register(MailingList, MailingListAdmin)\n```\n\nWith just a few lines of code you get a fully functional `ModelAdmin`, that will automatically pull in just the relevant related objects, based on `ForeignKey` relation between the two models, it will also auto set `ForeignKey` fields for nested relations and exclude them from change form when adding and editing objects on subadmin.\n\n### Screenshots\n\n![alt text](https://github.com/inueni/django-subadmin-example/raw/master/screenshots/subadmin_screenshot_1.png?raw=true)\n\n `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_.\n\n---\n\n![alt text](https://github.com/inueni/django-subadmin-example/raw/master/screenshots/subadmin_screenshot_2.png?raw=true)\n\n `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_.\n\n---\n\n ![alt text](https://github.com/inueni/django-subadmin-example/raw/master/screenshots/subadmin_screenshot_3.png?raw=true)\n\nWhen 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_.\n\n> If you want to see it in action, or get a more in-depth look at how to set everything up, check out .\n\n\n## Supported Django versions\n\nCurrent release of `django-subadmin` is **1.9.2** and is compatible with Django 1.9, 1.10 and 1.11.\n\n#### Verison numbering\n\n`django-subadmin` version numbers are related to Django version numbers. `django-subadmin` major and minor version numbers equal the minimal compatible django release.\n\n\n## Stability\n\n`django-subadmin` has evolved from code that has been running on production servers since early 2014 without any issues. Still, the code has been heavily refactored prior to public release, and while it is unlikely to eat your data, consider it **BETA** software.\n", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/inueni/django-subadmin/", "keywords": "django admin modeladmin foreignkey related field", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "django-subadmin", "package_url": "https://pypi.org/project/django-subadmin/", "platform": "", "project_url": "https://pypi.org/project/django-subadmin/", "project_urls": { "Homepage": "https://github.com/inueni/django-subadmin/" }, "release_url": "https://pypi.org/project/django-subadmin/1.9.2/", "requires_dist": null, "requires_python": "", "summary": "A special kind of ModelAdmin that allows it to be nested within another ModelAdmin", "version": "1.9.2" }, "last_serial": 3351501, "releases": { "1.9.0": [ { "comment_text": "", "digests": { "md5": "d1b1fbba38fecb3630d0337452d465e2", "sha256": "9848abf8c2793658bd426267b78e20ffa998ab325e6e962b222aa1ded8adda80" }, "downloads": -1, "filename": "django-subadmin-1.9.0.tar.gz", "has_sig": false, "md5_digest": "d1b1fbba38fecb3630d0337452d465e2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10771, "upload_time": "2017-11-13T22:44:58", "url": "https://files.pythonhosted.org/packages/bc/af/ece656d6a5db59635b1a255e67ca3067a0400ca74af8231bf40b017b49b0/django-subadmin-1.9.0.tar.gz" } ], "1.9.1": [ { "comment_text": "", "digests": { "md5": "3829ae9b4b34192758e2e16d6ff7b4de", "sha256": "c09052e8686811fcbc07e7739e95b8a2713aa54621dd8e04782c745c1824a0ca" }, "downloads": -1, "filename": "django-subadmin-1.9.1.tar.gz", "has_sig": false, "md5_digest": "3829ae9b4b34192758e2e16d6ff7b4de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11798, "upload_time": "2017-11-18T17:04:29", "url": "https://files.pythonhosted.org/packages/a6/77/eea5c031d0127f5182ba38bc1e44d7e7cc04423063e9f52fc912986c0491/django-subadmin-1.9.1.tar.gz" } ], "1.9.2": [ { "comment_text": "", "digests": { "md5": "25faff5bf7b4d019d6ae4dc4f956aa69", "sha256": "253ff740ca071aad1be2527c0100f15806dc4b75629c91096c46bade928265e7" }, "downloads": -1, "filename": "django-subadmin-1.9.2.tar.gz", "has_sig": false, "md5_digest": "25faff5bf7b4d019d6ae4dc4f956aa69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11385, "upload_time": "2017-11-21T09:09:11", "url": "https://files.pythonhosted.org/packages/5b/1b/c3d086868f9d1920b54d7a2a678a070b1a8a1b28a73943ddf35a57317788/django-subadmin-1.9.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "25faff5bf7b4d019d6ae4dc4f956aa69", "sha256": "253ff740ca071aad1be2527c0100f15806dc4b75629c91096c46bade928265e7" }, "downloads": -1, "filename": "django-subadmin-1.9.2.tar.gz", "has_sig": false, "md5_digest": "25faff5bf7b4d019d6ae4dc4f956aa69", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11385, "upload_time": "2017-11-21T09:09:11", "url": "https://files.pythonhosted.org/packages/5b/1b/c3d086868f9d1920b54d7a2a678a070b1a8a1b28a73943ddf35a57317788/django-subadmin-1.9.2.tar.gz" } ] }