Opened 7 years ago

Closed 6 years ago

#29439 closed Cleanup/optimization (needsinfo)

InlineAdminFormSet worked with forms array, but don't asks fieldset from every form in array

Reported by: Maxim Danilov Owned by: nobody
Component: contrib.admin Version: 2.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

in Django.contrib.admin.helpers.py (django 1.9)

i think this is wrong, to use only self.fieldsets, every form can have own fieldset attribute.

class InlineAdminFormSet(object):   
    def __iter__(self):
        for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()):
            view_on_site_url = self.opts.get_view_on_site_url(original)
            yield InlineAdminForm(self.formset, form, *!!wrong!!* self.fieldsets *!!wrong!!*,
                self.prepopulated_fields, original, self.readonly_fields,
                model_admin=self.opts, view_on_site_url=view_on_site_url)
......

it should be something like this:

class InlineAdminFormSet(object):   
	def __iter__(self):	
		for form, original in zip(self.formset.initial_forms, self.formset.get_queryset()):
			yield InlineAdminForm(self.formset, form, 
					*!!probably!!*
					[form.fieldset,] if hasattr(form, 'fieldset') else self.fieldsets
					*!!probably!!*,
					self.prepopulated_fields, original, self.readonly_fields,
					model_admin=self.opts)

Change History (1)

comment:1 by Tim Graham, 6 years ago

Resolution: needsinfo
Status: newclosed

Please include details to reproduce the problem. I can't tell what the problem is just based on the fix.

Note: See TracTickets for help on using tickets.
Back to Top