Thanks for the replies both. I know the difference between a NULL value and an empty string :-D. My question was more why Django recommends _never_ using null=True on CharFields.
>From both replies it sounds like neither of you agree with this guideline... On Thursday, May 3, 2018 at 2:18:32 PM UTC+1, Jani Tiainen wrote: > > And then you find out that Oracle implicitly converts empty strings to > NULLs which causes all kind of hassle. :) > > > On Thu, May 3, 2018 at 3:39 PM, Ken Whitesell <[email protected] > <javascript:>> wrote: > >> Nick, >> >> A null string (string with length 0) is _not_ the same as a null >> field (no string). The two are distinct, and (can) serve two very different >> functions. >> >> Take a look at this for some more detailed information: >> https://softwareengineering.stackexchange.com/questions/32578/sql-empty-string-vs-null-value >> >> Ken >> >> >> On Thursday, May 3, 2018 at 5:17:35 AM UTC-4, Nick Sarbicki wrote: >>> >>> I just saw this in the docs: >>> https://docs.djangoproject.com/en/2.0/ref/models/fields/#null >>> >>> Suggesting that you should never set a CharField to null unless using a >>> unique index. >>> >>> Is this generally accepted? Historically I've always nulled a CharField >>> because using empty strings, as opposed to letting a column be nullable, >>> has felt very dirty to me. >>> >>> I would have expected (not suggesting this as a change) an empty string >>> to fail if the field isn't nullable. >>> >>> Am I on my own here? >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> Visit this group at https://groups.google.com/group/django-users. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com >> >> <https://groups.google.com/d/msgid/django-users/23e3a4dc-345a-4fb9-8122-0dba7b99bb4d%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > > > -- > Jani Tiainen > > - Well planned is half done, and a half done has been sufficient before... > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c445d4ab-abf6-4cd6-9123-f9f2d0d8900d%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

