Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 22nd, 2012  |  syntax: None  |  size: 0.43 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Localizing CharFields and ModelForms with choices in Django
  2. from django.utils.translation import ugettext_lazy as _
  3.  
  4. class Item(models.Model):
  5.  
  6.     category = models.CharField(
  7.         max_length=256,
  8.         choices=(
  9.             ('car', _("Cars")),
  10.             ('computers', _("Computers")),
  11.             ('furry animal', _("Furry or large animals")),
  12.             ))
  13.  
  14.  
  15. class ItemForm(ModelForm):
  16.     class Meta:
  17.         model = Item