1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

[1.0.X] Fixed #9218 -- Simplified the fix from #9039 and added tests to ensure this case doesn't break again (and that the simplification didn't break anything).

[9341] from trunk.  Also updated svnmerge metadata.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9342 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Karen Tracey
2008-11-05 19:55:51 +00:00
parent 8e7eddd59d
commit dcfafea408
2 changed files with 32 additions and 2 deletions

View File

@@ -234,7 +234,7 @@ class BaseModelForm(BaseForm):
# equal NULL in SQL we should not do any unique checking for NULL values.
unique_checks = []
for check in self.instance._meta.unique_together[:]:
fields_on_form = [field for field in check if field in self.cleaned_data and not self.cleaned_data[field] is None]
fields_on_form = [field for field in check if self.cleaned_data.get(field) is not None]
if len(fields_on_form) == len(check):
unique_checks.append(check)
@@ -248,7 +248,7 @@ class BaseModelForm(BaseForm):
except FieldDoesNotExist:
# This is an extra field that's not on the ModelForm, ignore it
continue
if f.unique and name in self.cleaned_data and not self.cleaned_data[name] is None:
if f.unique and self.cleaned_data.get(name) is not None:
unique_checks.append((name,))
bad_fields = set()