Ticket #17856: ticket17856.diff

File ticket17856.diff, 1.7 KB (added by domguard, 12 years ago)
  • django/contrib/admin/options.py

    diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
    index 2071792..787cacd 100644
    a b class ModelAdmin(BaseModelAdmin):  
    343343        self.admin_site = admin_site
    344344        super(ModelAdmin, self).__init__()
    345345
    346     def get_inline_instances(self, request):
     346    def get_inline_instances(self, request, obj=None):
    347347        inline_instances = []
    348348        for inline_class in self.inlines:
    349349            inline = inline_class(self.model, self.admin_site)
    class ModelAdmin(BaseModelAdmin):  
    503503            fields=self.list_editable, **defaults)
    504504
    505505    def get_formsets(self, request, obj=None):
    506         for inline in self.get_inline_instances(request):
     506        for inline in self.get_inline_instances(request, obj):
    507507            yield inline.get_formset(request, obj)
    508508
    509509    def get_paginator(self, request, queryset, per_page, orphans=0, allow_empty_first_page=True):
    class ModelAdmin(BaseModelAdmin):  
    931931
    932932        ModelForm = self.get_form(request)
    933933        formsets = []
    934         inline_instances = self.get_inline_instances(request)
     934        inline_instances = self.get_inline_instances(request, obj=None)
    935935        if request.method == 'POST':
    936936            form = ModelForm(request.POST, request.FILES)
    937937            if form.is_valid():
    class ModelAdmin(BaseModelAdmin):  
    10291029
    10301030        ModelForm = self.get_form(request, obj)
    10311031        formsets = []
    1032         inline_instances = self.get_inline_instances(request)
     1032        inline_instances = self.get_inline_instances(request, obj)
    10331033        if request.method == 'POST':
    10341034            form = ModelForm(request.POST, request.FILES, instance=obj)
    10351035            if form.is_valid():
Back to Top