# HG changeset patch # User dellsystem # Date 1346394537 14400 # Node ID d858aae811d0fe23377ac723c51fa98a4e6d2017 # Parent 5a8f1dece263f59a80bc402ca46a70daa56bca7e Move choices for lexer field from SnippetForm to Snippet The choices should be on the model, because it's more logical and because now we can print out the human-readable value of the field directly from the model, using snippet.get_FIELD_display() (e.g. get_lexer_display()). diff -r 5a8f1dece263 -r d858aae811d0 apps/snippet/forms.py --- a/apps/snippet/forms.py Fri Aug 31 02:26:22 2012 -0400 +++ b/apps/snippet/forms.py Fri Aug 31 02:28:57 2012 -0400 @@ -20,11 +20,6 @@ class SnippetForm(forms.ModelForm): - lexer = forms.ChoiceField( - choices=LEXER_LIST, - initial=LEXER_DEFAULT, - label=_(u'Lexer'), - ) expire_options = forms.ChoiceField( choices=EXPIRE_CHOICES, initial=EXPIRE_DEFAULT, diff -r 5a8f1dece263 -r d858aae811d0 apps/snippet/models.py --- a/apps/snippet/models.py Fri Aug 31 02:26:22 2012 -0400 +++ b/apps/snippet/models.py Fri Aug 31 02:28:57 2012 -0400 @@ -20,7 +20,10 @@ content = models.TextField(_(u'Content'), ) content_highlighted = models.TextField(_(u'Highlighted Content'), blank=True) - lexer = models.CharField(_(u'Lexer'), max_length=30, default=LEXER_DEFAULT) + lexer = models.CharField(_(u'Lexer'), + max_length=30, + choices=LEXER_LIST, + default=LEXER_DEFAULT) published = models.DateTimeField(_(u'Published'), blank=True) expires = models.DateTimeField(_(u'Expires'), blank=True, help_text='asdf') parent = models.ForeignKey('self', null=True, blank=True,