Re: Custom Select widget choices - how to reuse choices?

2008-11-22 Thread Donn
On Saturday, 22 November 2008 03:52:27 Jeff FW wrote: > choices = Movie._meta.get_field('disk_type').choices Ah, the 'Movie' in there was the missing voodoo. I was stuck on using an instance; and yes, I prefer Movie dot choices 'global' idea. Thanks for the various replies. I have more-or-less

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Jeff FW
You could define the CHOICES as a member of your model class, like so: class Movie( Relic ): CHOICES=((u'1','one'), (u'2',u'two')) disk_type = models.CharField( 'Type', max_length=8, choices=CHOICES) Then, in your form: class MovieForm( BasicRelicForm ): disk_type =

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 13:46:35 Daniel Roseman wrote: > There is an alternative, though: instead of overriding the fields > declaratively, you can define a formfield_callback function. This seems interesting. I have searched the docs online for 'formfield_callback' and get no useful

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Daniel Roseman
On Nov 21, 9:09 am, Donn <[EMAIL PROTECTED]> wrote: > On Friday, 21 November 2008 08:06:32 urukay wrote: > > > easy way how to solve it is to put definition of your choices out of model > > definition: > > Yeah, that's what I call a 'global', but is there no way to get the choices > from the

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread urukay
> -- View this message in context: http://www.nabble.com/Custom-Select-widget-choices---how-to-reuse-choices--tp20606743p20617654.html Sent from the django-users mailing list archive at Nabble.com. --~--~-~--~~~---~--~~ You received this message because

Re: Custom Select widget choices - how to reuse choices?

2008-11-21 Thread Donn
On Friday, 21 November 2008 08:06:32 urukay wrote: > easy way how to solve it is to put definition of your choices out of model > definition: Yeah, that's what I call a 'global', but is there no way to get the choices from the field in the model class? \d

Re: Custom Select widget choices - how to reuse choices?

2008-11-20 Thread urukay
ly '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. --~--~---

Custom Select widget choices - how to reuse choices?

2008-11-20 Thread Donn
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,