Re: Nullable vs empty strings

2018-05-03 Thread George Lubaretsi
Short answer: because you'll know when you need it. And unless that's the case - there's no good reason to do it. Long answer: Because there's really no reason to do it except for when you have unique constraint on that column. It's just a convention. When you have a `CharField`, you expect

Re: Nullable vs empty strings

2018-05-03 Thread Nick Sarbicki
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

Re: Nullable vs empty strings

2018-05-03 Thread Jani Tiainen
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 wrote: > Nick, > > A null string (string with length 0) is _not_ the same as a null > field (no string).

Re: Nullable vs empty strings

2018-05-03 Thread Ken Whitesell
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:

Nullable vs empty strings

2018-05-03 Thread Nick Sarbicki
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