Skip to content

Instantly share code, notes, and snippets.

@stephane
Last active August 26, 2015 20:05
Show Gist options
  • Save stephane/70fb12d7be299149d710 to your computer and use it in GitHub Desktop.
Save stephane/70fb12d7be299149d710 to your computer and use it in GitHub Desktop.
Django - Many to many with fixed list of choices
class Issue(models.Model):
title = models.CharField(max_length=256)
class Label(models.Model):
issue = models.ForeignKey(Issue, related_name='labels')
NAME_CHOICES = (
('bug', "Bug"),
('feature', "Feature"),
('blocker', "Release blocker"),
)
name = models.CharField(max_length=32, choices=NAME_CHOICES)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment