Skip to content

Instantly share code, notes, and snippets.

@moacirmoda
Created August 9, 2018 20:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save moacirmoda/1ffdca39b24d7c7b87c9381465b92d34 to your computer and use it in GitHub Desktop.
class Car(models.Model):
RED = 'r'
WHITE = 'w'
BLUE = 'b'
COLOR_CHOICES = (
(RED, 'red'),
(WHITE, 'white'),
(BLUE, 'blue'),
)
color = models.CharField(max_length=5, choices=COLOR_CHOICES, default=RED)
>>> Car.objects.filter(color=Car.RED)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment