diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-11-01 22:25:41 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-11-01 22:25:41 +0000 |
| commit | 83af0b8ff355698a3aa436bad851156c9619f7ee (patch) | |
| tree | 5e3fde686b7f9fd70f5997c5f7d1054dedb6963f /django | |
| parent | 1f69b11ef534bef2a837870cd59cd9cd658aec3d (diff) | |
Fixed #9494 -- Ensure the foreign key in an inline formset is always present on the forms. Thanks Fugazi for the report.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9326 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/forms/models.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 7f49324ff7..99f7ef5bfb 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -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, |
