Opened 4 years ago

Closed 4 years ago

#15282 closed (invalid)

inlineformset_factory ignores overrides on base_fields when a form class is passed in

Reported by: coleifer Owned by: nobody
Component: Forms Version: 1.2
Severity: Keywords: inlineformset_factory, ModelFormMetaclass
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When using inlineformset_factory with your own Form class, any overrides present in the base_fields do not carry over to the form of the generated formset.

Looking at http://code.djangoproject.com/browser/django/trunk/django/forms/models.py#L216 if a declared_field is overridden it will be updated correctly, but updates to base_fields do not.

My specific use-case: hooking into the admin inline's get_formset() method, I want to be able to alter the queryset of certain inline form fields on a per-request basis. Code here http://code.djangoproject.com/browser/django/trunk/django/contrib/admin/options.py#L1297

Attachments (2)

testcase.diff (1.6 KB) - added by coleifer 4 years ago.
testcase indicating failure
patch.diff (751 bytes) - added by coleifer 4 years ago.
Patch

Download all attachments as: .zip

Change History (4)

Changed 4 years ago by coleifer

testcase indicating failure

Changed 4 years ago by coleifer

Patch

comment:1 Changed 4 years ago by coleifer

  • Has patch set
  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

comment:2 Changed 4 years ago by anonymous

  • Resolution set to invalid
  • Status changed from new to closed

base_fields is not a public API, so this isn't a bug. Reopen if there's a manifestation of the issue that can be triggered without poking directly at base_fields.

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