About Boolean Fields

When creating boolean fields, make sure to state them positively. They will be represented as checkmarks in the administration and it will be less confusing.

DO:

1
2
3
4
class Post(models.Model):
    is_shown = models.BooleanField(default=True)
    is_featured = models.BooleanField(default=False)
    is_published = models.BooleanField(default=False)

DON'T:

1
2
3
4
class Post(models.Model):
    is_hidden = models.BooleanField(default=False)
    is_regular = models.BooleanField(default=True)
    is_draft = models.BooleanField(default=True)

Tips and Tricks Programming Development Django 4.2 Django 3.2 Django 2.2