mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
[1.0.X] Fixed #9494 -- Ensure the foreign key in an inline formset is always present on the forms. Thanks Fugazi for the report.
Backport of r9326 from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9327 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -539,6 +539,13 @@ def inlineformset_factory(parent_model, model, form=ModelForm,
|
||||
# enforce a max_num=1 when the foreign key to the parent model is unique.
|
||||
if fk.unique:
|
||||
max_num = 1
|
||||
if fields is not None:
|
||||
fields = list(fields)
|
||||
fields.append(fk.name)
|
||||
else:
|
||||
# get all the fields for this model that will be generated.
|
||||
fields = fields_for_model(model, fields, exclude, formfield_callback).keys()
|
||||
fields.append(fk.name)
|
||||
kwargs = {
|
||||
'form': form,
|
||||
'formfield_callback': formfield_callback,
|
||||
|
||||
Reference in New Issue
Block a user