21👍
Your code should work. Perhaps something is setting the empty value to a non-null value (like an empty string). I’d have to see the full error message.
Since this is an old thread, I’m going to post the answer to the question I came here for, “How do you set FloatField default to Null in the database?”
cost = models.FloatField(null=True, blank=True, default=None)
10👍
Float Field is quite related to Decimal Field so, probably it should take a default argument. Try doing this..
cost = models.FloatField(default=to_some_value)
- How to apply a filter backend to all fields of all resources in Django Rest Framework?
- Related name for recursive many to many relationship not working
- Django Test Client post() returns 302 despite error on view's post()
- Email as username in Django
- How do you access query params in a Django Rest Framework 3.0 serializer?
Source:stackexchange.com