On Wed, May 20, 2009 at 1:38 PM, Bobby Roberts <tchend...@gmail.com> wrote:
> > > You don't access the class at forms.MyModeChoiceField, since it doesn't > live > > in that namespace. You access it with just MyModelChocieField, since > it's > > defined in the same file. As a note, you're going to want to have the > > MyModelChoiceField class before your form (in the file), otherwise the > Field > > won't be defined when you go to use it. > > > > Alex > > > > Alex - > > I really appreciate your help. I made the changes you suggested and > it's shown here: > > class MyModelChoiceField (ModelChoiceField): > def label_from_instance(self,obj): > return "My Object #%i" % obj.id > > class FrmWebPage (forms.Form): > active = forms.ChoiceField(required=True, choices=active_choices, > widget=forms.RadioSelect(attrs={'class':'choiceselect'})) > page_category_id = MyModelChoiceField > (queryset=PageCategory.objects, empty_label='Choose',required=True, > widget=forms.Select(attrs={'class':'dropbox'})) > > [snip] > > page_weight = MyModelChoiceField(required=True, > choices=weight_choices, widget=forms.Select(attrs= > {'class':'dropbox'})) > > > and the result is: > > name 'ModelChoiceField' is not defined > > > Your class should inherit from "forms.ModelChoiceField", not just ModelChocieField. Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---