#4136: NULL fields and Unique keys -------------------------------------------------------+-------------------- Reporter: David Cramer <dcra...@gmail.com> | Owner: nobody Status: new | Milestone: Component: django.contrib.admin | Version: 0.96 Resolution: | Keywords: Stage: Accepted | Has_patch: 0 Needs_docs: 1 | Needs_tests: 0 Needs_better_patch: 0 | -------------------------------------------------------+-------------------- Comment (by adamnelson):
I tried this model definition: class Tester(models.Model): mac_address = models.CharField(max_length=12, blank=True, null=True, default=None, unique=True) The admin did indeed give a duplicate key error when trying to add a blank value twice. With a default of None (Null), I think the admin should submit None for a blank field, and therefore no key constraint should hit (since None != None or Null != Null). In the case where default is not set or is not None then I think an empty string is the correct value. -- Ticket URL: <http://code.djangoproject.com/ticket/4136#comment:8> Django <http://code.djangoproject.com/> The Web framework for perfectionists with deadlines. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django updates" group. To post to this group, send email to django-updates@googlegroups.com To unsubscribe from this group, send email to django-updates+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-updates?hl=en -~----------~----~----~----~------~----~------~--~---