Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
from django.db import models
optional = dict(blank=True, null=True)
class Foo(models.Model):
bar = models.CharField()
baz = models.CharField(**optional)

This comment has been minimized.

Copy link

haplo commented Dec 28, 2011

TextField and CharField (and other fields inheriting from CharField) shouldn't have null=True, because then you can store both a NULL and a blank string as the empty value, it's better to use only blank=True for those cases.

This is explained in the Django documentation:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.