{
"info": {
"author": "Pavel Savchenko",
"author_email": "pavel@modlinltd.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 5 - Production/Stable",
"Environment :: Web Environment",
"Framework :: Django",
"Framework :: Django :: 1.4",
"Framework :: Django :: 1.5",
"Framework :: Django :: 1.6",
"Framework :: Django :: 1.7",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 2.7"
],
"description": "ModelAdmin-Utils\r\n================\r\n\r\nA collection of useful Django ``admin.ModelAdmin`` mixins and template\r\ntags\r\n\r\nInstallation\r\n============\r\n\r\n::\r\n\r\n pip install Django-modeladmin-utils\r\n\r\nLimitInlinesAdminMixin\r\n======================\r\n\r\nIntro\r\n-----\r\n\r\nOccasionally, a relation to a specified object may include quite a few\r\nobject. In this case, a large list of inlines will be rendered, which\r\nmay not be desired.\r\n\r\nUsage\r\n~~~~~\r\n\r\nSimply add LimitInlinesAdminMixin to the parent ModelAdmin, and specify\r\nthe inlines to be limited in the attribute ``limit_inlines``. The number\r\nof entries shown is determined by ``settings.INLINES_MAX_LIMIT``\r\n(defaults to 15).\r\n\r\n::\r\n\r\n from modeladmin_utils.mixins import LimitInlinesAdminMixin\r\n\r\n # ...\r\n\r\n class SomeParentModelAdmin(LimitInlinesAdminMixin, admin.ModelAdmin):\r\n inlines = (MyRelationInline, AnotherRelativeInline)\r\n limit_inlines = (MyRelationInline, )\r\n\r\nTemplate: Link to \"show all\" entries\r\n------------------------------------\r\n\r\nAdditionally to limiting, you may also display in the header of the\r\ninline container a link to related object changelist, filtered by\r\nrelated entries only. This is achievable by the use of a ``templatetag``\r\nprovided in this package. Overriding the admin templates for the\r\nrelevant inline/s is easy:\r\n\r\n::\r\n\r\n {% link_to_changelist inline_admin_formset original as changelist_url %}\r\n {% if changelist_url %}\r\n ({{inline_admin_formset.formset.limited_count}} / {{inline_admin_formset.formset.total_count}} displayed - {% trans \"Detailed View\" %})\r\n {% endif %}\r\n\r\nNotes\r\n-----\r\n\r\n1. To use the ``templatetag``, the app must be added to the\r\n ``settings.INSTALLED_APPS``:\r\n\r\n ::\r\n\r\n INSTALLED_APPS += (\r\n 'modeladmin_utils',\r\n )\r\n\r\n2. Examples of modified templates of both stacked and tabular inlines,\r\n based on Django 1.4 templates, are provided in this package (in\r\n ``templates/admin/edit_inlines``). However, these are not used by\r\n default to avoid confusion, to use them simply copy the template\r\n over, modify (see below in specific instructions) and set inline\r\n ``template`` attribute, e.g:\r\n\r\n ::\r\n\r\n class MyRelationInline(admin.TabularInline):\r\n template = 'path_to_your/templates/admin/edit_inlines/tabular.html'\r\n\r\n3. While the related model for the changelist is automatically\r\n determined, you may also specify an alternative model by specifying\r\n the ``unlimited_changelist_model`` attribute on the inline. This is\r\n useful if the inline is for a \"through model\" but the link should lead to\r\n the target model.\r\n\r\n ::\r\n\r\n class MyRelationInline(admin.TabularInline):\r\n unlimited_changelist_model = 'myapp.MyTargetModel'\r\n\r\nCustomizing template example\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n\r\nto add the link to a stacked template, copy over your original\r\ntemplates/admin/edit\\_inline/stacked.py, and place the code above in the\r\ndiv.tabular-header like so (note that I'm using a\r\n`django-grappelli `__ template here):\r\n\r\n::\r\n\r\n {% load modeladmin_links %}\r\n\r\n {# ... #}\r\n {% link_to_changelist inline_admin_formset original as changelist_url %}\r\n