Skip to content

Instantly share code, notes, and snippets.

Embed
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)
@haplo

This comment has been minimized.

Copy link

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: https://docs.djangoproject.com/en/1.3/ref/models/fields/#null

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.