#16089: Adding/Removing admin Inlines on the fly
-------------------------+-------------------------------
Reporter: sheep2 | Owner: nobody
Type: New feature | Status: new
Milestone: | Component: contrib.admin
Version: 1.3 | Severity: Normal
Keywords: | Triage Stage: Unreviewed
Has patch: 1 | Easy pickings: 0
-------------------------+-------------------------------
Inlines are very useful for creating/updating related objects at the same
time. However, sometimes you only want to create/update one of the
objects instead of both. For example, when creating a User you may not
want to add the associated content in a related profile model, but want to
do so later.
The current implementation defines and instantiates the inlines when a
admin.ModelAdmin class is instantiated, but does not allow
addition/removal of more inlines anywhere(or anytime) else.
I propose two functions register_inline_instance() and
unregister_inline_instance() that allow inlines to be added and removed
from a model on the fly.
Example usage:
{{{
class UserAdmin(admin.ModelAdmin):
inlines = [StudentInline,]
...
def add_view(self, request, form_url='', extra_context=None):
self.unregister_inline_instance(StudentInline)
return super(UserAdmin, self).add_view(request, form_url,
extra_context)
def change_view(self, request, form_url='', extra_context=None):
self.register_inline_instance(StudentInline)
return super(UserAdmin, self).change_view(request, form_url,
extra_context)
...
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16089>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.