On 11/11/10 01:40, Karen Tracey wrote:
>
> There is a way, it just requires some admin customization. See:
>
> http://stackoverflow.com/questions/454436/unique-fields-that-allow-nulls-in-django/1400046#1400046

Right, and you can also register a pre_save hook to fix this, but it's
just ugly.

>
> I don't think we can do anything now that would suddenly, when people
> installed a new level of Django, start storing nulls in cases where
> previously empty strings had been stored. Wouldn't we then likely be
> creating a situation where a table column winds up with some "empty"
> values equal to empty strings an others nulls? Having just one "empty"
> value is the reason empty strings are forced for null values,
> according to the doc. Personally I may wish null had been chosen as
> the empty value but I'm not sure we can safely make that change at
> this point. (I am tired, though, so maybe I am missing something in
> how this would not be a backwards-incompatible change?)

Yes, my main problem with this is backwards-compatability - as you say,
whenever people started saving forms again, things would suddenly become
None, which is never a Good Thing.

We could do it only when the field is unique=True null=True (since if
you have that chances are you _really didn't_ want an empty string), but
that also presents the additional weirdness of it changing only when
very specific field options are turned on.

The other options are to improve the error message a bit (but doing so
while keeping it end-user friendly is tricky) or to add an option to
ModelAdmin (because what that class needs is more options...)

But yes, the main issue here is the underlying issue that Django has
been using "" for empty strings since the start, which can be a divisive
issue amongst the developers I know. Something to chalk up for the
fabled Django 2, perhaps.

Andrew

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to