Ticket #17856: adding_obj_parameter_to_get_inline_instances.diff

File adding_obj_parameter_to_get_inline_instances.diff, 1.4 KB (added by ybon, 13 years ago)

Adding "obj" parameter to get_inline_instances method in contrib.admin

  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index f5f6256..e6749ba 100644
    a b class ModelAdmin(BaseModelAdmin):  
    345345        self.admin_site = admin_site
    346346        super(ModelAdmin, self).__init__()
    347347
    348     def get_inline_instances(self, request):
     348    def get_inline_instances(self, request, obj=None):
    349349        inline_instances = []
    350350        for inline_class in self.inlines:
    351351            inline = inline_class(self.model, self.admin_site)
    class ModelAdmin(BaseModelAdmin):  
    505505            fields=self.list_editable, **defaults)
    506506
    507507    def get_formsets(self, request, obj=None):
    508         for inline in self.get_inline_instances(request):
     508        for inline in self.get_inline_instances(request, obj):
    509509            yield inline.get_formset(request, obj)
    510510
    511511    def get_paginator(self, request, queryset, per_page, orphans=0, allow_empty_first_page=
    class ModelAdmin(BaseModelAdmin):  
    10311031
    10321032        ModelForm = self.get_form(request, obj)
    10331033        formsets = []
    1034         inline_instances = self.get_inline_instances(request)
     1034        inline_instances = self.get_inline_instances(request, obj)
    10351035        if request.method == 'POST':
    10361036            form = ModelForm(request.POST, request.FILES, instance=obj)
    10371037            if form.is_valid():
Back to Top