Skip to content

Instantly share code, notes, and snippets.

@nikolaygit
Created October 16, 2013 15:14
Show Gist options
  • Save nikolaygit/7009319 to your computer and use it in GitHub Desktop.
Save nikolaygit/7009319 to your computer and use it in GitHub Desktop.
Django Model Choices
# -*- coding: utf-8 -*-
from django.db import models
from django.utils.translation import ugettext_lazy as _
class YourModel(models.Model):
CATEGORY_CHOICES = (
('id1', _('Your Text 1')),
('id2', _('Your Text 2')),
('id3', _('Your Text 3')),
)
category_choice = models.CharField(_('Category Choice'), max_length=100,
choices=CATEGORY_CHOICES, default=CATEGORY_CHOICES[0][0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment