I read the document 
<https://docs.djangoproject.com/en/1.11/ref/models/fields/#null> 
about field options 'null'.

It is said that.

If True, Django will store empty values as NULL in the database. Default is 
> False.
>
> Avoid using null 
> <https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.Field.null>
>  on 
> string-based fields such as CharField 
> <https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.CharField>
>  and TextField 
> <https://docs.djangoproject.com/en/1.11/ref/models/fields/#django.db.models.TextField>.
>  
> If a string-based field has null=True, that means it has two possible 
> values for “no data”: NULL, and the empty string.
>

Then I try make a field have "null=True", just save it to database.

like that.

>>> from backend.models import Scrapyd as S
>>> s = S()
>>> s.comment
>>> type(s.comment)
<class 'NoneType'>
>>> s.save()
>>> b  = S.objects.all().last()
>>> b
<Scrapyd: Scrapyd object>
>>> b.comment
>>> type(b.comment)
<class 'NoneType'>


*What my question is why the value not like the document  
<https://docs.djangoproject.com/en/1.11/ref/models/fields/#null>said is 
empty string ''?*

*I am confused.*

-- 
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/1b239340-78d6-4df2-a12d-9531dfe7912d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to