summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorHonza Král <honza.kral@gmail.com>2010-10-13 00:33:10 +0000
committerHonza Král <honza.kral@gmail.com>2010-10-13 00:33:10 +0000
commit18a605d6ad1041d413f59876bef62b6f9c275ea2 (patch)
treefe2550c8a33e62fa7c3f25bc7f67f9ff1e9d7e66 /django
parent4ed10675f953e4349ecd3ad386ef5c8485d0220f (diff)
[1.2.X] Changed unique validation in model formsets to ignore None values, not just omit them. Thanks claudep!
Backport of r14193 from trunk. git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@14194 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/forms/models.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/django/forms/models.py b/django/forms/models.py
index 16a4f206b8..d4046a7f70 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -516,10 +516,9 @@ class BaseModelFormSet(BaseFormSet):
# it's already invalid
if not hasattr(form, "cleaned_data"):
continue
- # get each of the fields for which we have data on this form
- if [f for f in unique_check if f in form.cleaned_data and form.cleaned_data[f] is not None]:
- # get the data itself
- row_data = tuple([form.cleaned_data[field] for field in unique_check])
+ # get data for each field of each of unique_check
+ row_data = tuple([form.cleaned_data[field] for field in unique_check if field in form.cleaned_data])
+ if row_data and not None in row_data:
# if we've aready seen it then we have a uniqueness failure
if row_data in seen_data:
# poke error messages into the right places and mark