I have a model with this field:

my_field = models.CharField(max_length=100, default='') 

I have the default set to empty string but when I create an object with my_field="", it says "This field cannot be blank". Does default='' not imply that it can be blank? Do I have to explicitly set the blank=True?

1 Answer

Yes, you need to set blank=True.

my_field = models.CharField(max_length=100, default='', blank=True) 
1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.