Last modified 6 years ago. Download all attachments as:. I think this behavior ir related to the convention used by Django for CharField 's and TextField 's with no value, the rationale is explained in the section of documentation that describes the null field option:.
This is by design and fully documented. Changing the existing Django behaviour would be backwards-incompatible. Following mtredinnick's suggestion and some teeth grinding , here's how to subclass a CharField to make it store NULL:.
The behavior is contrary to documentation. Documentation says "Avoid using null on string-based fields such as CharField and TextField unless you have an excellent reason. This is my case. Don't reopen a ticket which has been closed as "wontfix" by a committer. If you disagree, bring up the issue on the django-developers mailing list.
I'm not using any forms or the admin site though - this is all through code. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown.
The Overflow Blog. Stack Gives Back Safety in numbers: crowdsourcing data on nefarious IP addresses. Featured on Meta. New post summary designs on greatest hits now, everywhere else eventually. Related Hot Network Questions. I was so focused on looking for "blank" that I most have missed it in the docs. Write your comment as an answer so I can accept it and upvote it. Thank you!
Add a comment. Active Oldest Votes. Improve this answer. Khairul Basar 4, 11 11 gold badges 41 41 silver badges 53 53 bronze badges. Alagappan Ramu Alagappan Ramu 2, 7 7 gold badges 26 26 silver badges 35 35 bronze badges. Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog.
0コメント