Created
December 28, 2011 05:16
-
-
Save amccloud/1526444 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
optional = dict(blank=True, null=True) | |
class Foo(models.Model): | |
bar = models.CharField() | |
baz = models.CharField(**optional) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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