Ticket #9218: key-error-on-empty-pk-field-in-forms-fix-using-get.patch

File key-error-on-empty-pk-field-in-forms-fix-using-get.patch, 628 bytes (added by romke <rombar@…>, 16 years ago)

patch using get(name) as suggested

  • forms/models.py

     
    232232                continue
    233233            # MySQL can't handle ... WHERE pk IS NULL, so make sure we
    234234            # don't generate queries of that form.
    235             is_null_pk = f.primary_key and self.cleaned_data[name] is None
     235            is_null_pk = f.primary_key and self.cleaned_data.get(name) is None
    236236            if name in self.cleaned_data and f.unique and not is_null_pk:
    237237                unique_checks.append((name,))
    238238               
Back to Top