diff options
| author | Brian Rosner <brosner@gmail.com> | 2008-10-28 20:01:03 +0000 |
|---|---|---|
| committer | Brian Rosner <brosner@gmail.com> | 2008-10-28 20:01:03 +0000 |
| commit | 524a44e20b42995ba67db8aadc781a9270117b59 (patch) | |
| tree | 4b54ff2be719bcabf5c15a8641573be4ee0fe8fe /django | |
| parent | 202693460096c1d5f4a614dd4facc5af1a9599de (diff) | |
Fixed #9462 -- Set the instance in an inline formset correctly so that None does not get passed through to the queryset. Thanks tobias and copelco for the ticket.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9293 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/forms/models.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/django/forms/models.py b/django/forms/models.py index 180aec60db..0c98f52660 100644 --- a/django/forms/models.py +++ b/django/forms/models.py @@ -446,7 +446,10 @@ class BaseInlineFormSet(BaseModelFormSet): def __init__(self, data=None, files=None, instance=None, save_as_new=False, prefix=None): from django.db.models.fields.related import RelatedObject - self.instance = instance + if instance is None: + self.instance = self.model() + else: + self.instance = instance self.save_as_new = save_as_new # is there a better way to get the object descriptor? self.rel_name = RelatedObject(self.fk.rel.to, self.model, self.fk).get_accessor_name() |
