On Thu, Apr 08, 2021 at 11:12:51PM +0100, Roger Gammans wrote: > On Thu, 2021-04-08 at 16:36 -0500, Ryan Nowakowski wrote: > > On Wed, Apr 07, 2021 at 03:25:53PM +0100, Roger Gammans wrote: > > > This is mostly (form the Django perspective) and issue with > > > CharFields, > > > because a CharField can store None or ''. For values of '' > > > in CharField, IIRC, django will convert them to null, with > > > null=True, > > > blank=True. But not with blank=True,null=False.See also : > > > https://docs.djangoproject.com/en/3.1/ref/models/fields/#null > > > > I read the documentation a bit differently. My interpretation is > > that > > CharField(null=True) means that both ''(empty string) and None(null) > > are > > valid values. But no implicit conversion from '' to None takes > > place. > > > > CharField(null=False) means that None(null) isn't a valid value and > > that > > only ''(empty string) is permitted. > > I understand that reading, and the simple answer is we are both right! > > See: > https://github.com/django/django/blob/45a58c31e64dbfdecab1178b1d00a3803a90ea2d/django/db/models/fields/__init__.py#L1082 > > This shows the model field telling the any auto creating form field, > say like in the admin model, which value to prefer 'empty' values. > > Since it's not the model field, so any python code which saves '' and > None, directed onto the model will still have those respected as '' and > NULL.
Whhhhhyyyyyyyy Oracle!!!!!!! *sigh* :) find django/db/backends -name "features.py" | xargs grep interprets_empty_strings_as_nulls django/db/backends/oracle/features.py: interprets_empty_strings_as_nulls = True django/db/backends/base/features.py: interprets_empty_strings_as_nulls = False -- 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 django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20210408224331.GP15054%40fattuba.com.