easy way how to solve it is to put definition of your choices out of model definition:
CHOICES=((u'1','one'), (u'2',u'two')) class Movie( Relic ): disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES) and then you can import CHOICES whereever you want and reuse it from ......models import CHOICES Donn Ingle wrote: > > > Hello, > In my model, I define the choices for a charfield. I make a ModelForm of > that > model but I want my own widget for that field. How can I pass-through the > choices I defined in my model? > > Some code: > > class Movie( Relic ): > disk_type = models.CharField( 'Type', max_length=8, > choices=((u'1','one'), > (u'2',u'two')), default=u'1' ) > > class MovieForm( BasicRelicForm ): > disk_type = forms.CharField( widget = choicewidget( choices=?? )) > class Meta: > model = Movie > > What would I put in the choices=?? line? > > I have found this voodoo: > forminstance._meta.model.disk_type.choices > But it needs an instance to work. > > I could use a global var and repeat it twice, but I'd like to know if > there's > a way to simply 'fetch' it from the model. > > Any clues? > \d > > > > > -- View this message in context: http://www.nabble.com/Custom-Select-widget-choices---how-to-reuse-choices--tp20606743p20615699.html Sent from the django-users mailing list archive at Nabble.com. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---