Null is not an empty string!
select count(*) from table where xyz is null is not the same as select count(*) from table where xyz == ''!
If I have a unique constraint on a column, multiple NULL values can exist. Multiple empty strings cannot!
I know what the difference is. I don't need an explanation. All I want to know is how to insert a NULL value in Django admin.
I have tried:
default=None
null=True
No I don't want blank. I want NULL.
When I look at my schemas from my migrations, I clearly see the columns allow NULL.
So, what is the fiddly little syntax in dynamically typed python that seems to be burred on the by the SEO of people who don't understand what constraints are?
This field is required.
No it's not. I can clearly see that from the table structure.
You have to provide blank=True as well, so django admin will allow you set empty strings.
For example I tested it on this model:
class NullFieldModel(models.Model):
title = models.CharField(max_length=100, null=True, default=None, blank=True)
and it worked with sqlite. Following query respond me with new model:
SELECT * FROM testapp_nullfieldmodel WHERE testapp_nullfieldmodel.title IS NULL
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With