Ticket #13811: formset_validation.diff

File formset_validation.diff, 1.1 KB (added by Claude Paroz, 14 years ago)

Ignore when any unique constraint member is None

  • django/forms/models.py

     
    510510                # it's already invalid
    511511                if not hasattr(form, "cleaned_data"):
    512512                    continue
    513                 # get each of the fields for which we have data on this form
    514                 if [f for f in unique_check if f in form.cleaned_data and form.cleaned_data[f] is not None]:
    515                     # get the data itself
    516                     row_data = tuple([form.cleaned_data[field] for field in unique_check])
     513                # get data for each field of each of unique_check
     514                row_data = tuple([form.cleaned_data[field] for field in unique_check if field in form.cleaned_data])
     515                if row_data and not None in row_data:
    517516                    # if we've aready seen it then we have a uniqueness failure
    518517                    if row_data in seen_data:
    519518                        # poke error messages into the right places and mark
Back to Top