Don Arbow wrote:
> Yes, from the documentation:
>
> http://www.djangoproject.com/documentation/model_api/#null
>
> "Note that empty string values will always get stored as empty
> strings, not as NULL -- so use null=True for non-string fields such
> as integers, booleans and dates.
>
> Avoid using null on string-based fields such as CharField and Text
> Field unless you have an excellent reason. If a string-based field
> has null=True, that means it has two possible values for "no
> data":NULL, and the empty string. In most cases, it's redundant to
> have two possible values for "no data"; Django convention is to use
> the empty string, not NULL."

Ok, after some trial and error, I see that if you have null=True on a
CharField, it will use NULL instead of empty string.  This is what I
needed because in my model I have a field that I want to be optional
but unique.  This is not possible if you don't put null=True for the
field because Django will try to use empty string by default.

Out of curiosity, any one know for what reason using empty strings for
CharFields is the Django convention?  Technically, isn't an empty
string still data?  Isn't it a bit confusing that some fields get
default values and others do not?  Explicit better than implicit?


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers
-~----------~----~----~----~------~----~------~--~---

Reply via email to