summaryrefslogtreecommitdiff
path: root/django/forms/models.py
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2010-01-26 15:02:53 +0000
committerJannis Leidel <jannis@leidel.info>2010-01-26 15:02:53 +0000
commitc14937cf7a1e8c25702e89485cc2dd33aa0d3a16 (patch)
tree41894e28b3b2ba2e5c0c8adfea919f2553835644 /django/forms/models.py
parentdf82175c17667b76ac968e059583f795b8909526 (diff)
Fixed #12508 - Added ability to dynamically add inlines in the admin app.
Refs #13. Also introduces an ``empty_form`` attribute on formsets to make it easier to implement dynamic forms. Many thanks to Zain Memon for the initial patch from his Summer of Code 2009 project, Stanislaus Madueke for his django-dynamic-formset app and all the other people helping out. git-svn-id: http://code.djangoproject.com/svn/django/trunk@12297 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/forms/models.py')
-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 ec28b446bd..f343a1cbcd 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -620,7 +620,10 @@ class BaseModelFormSet(BaseFormSet):
pk_value = form.instance.pk
else:
try:
- pk_value = self.get_queryset()[index].pk
+ if index is not None:
+ pk_value = self.get_queryset()[index].pk
+ else:
+ pk_value = None
except IndexError:
pk_value = None
if isinstance(pk, OneToOneField) or isinstance(pk, ForeignKey):