summaryrefslogtreecommitdiff
path: root/django/forms
diff options
context:
space:
mode:
authorBrian Rosner <brosner@gmail.com>2008-10-28 20:03:56 +0000
committerBrian Rosner <brosner@gmail.com>2008-10-28 20:03:56 +0000
commit38d9b0919bb07f4dcfcf22a9013b1a711f54ab89 (patch)
treed60379ee21966a5271ee60927acf666f8eae2a22 /django/forms
parent84216ef05e6099235559a9a018bf4e0ad6ecff70 (diff)
[0.5.X] 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.
Backport of r9293 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9294 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms')
-rw-r--r--django/forms/models.py5
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()