On Thu, Jun 11, 2009 at 12:13 PM, Bobby Roberts <tchend...@gmail.com> wrote:

>
> hi group....
>
> i'm trying to create a drop box that is populated with a distinct list
> of values from a certain field  (fieldname=page_plaque) in the table.
> Here is what i have in my forms.py
>
>
> class PagePlaqueModelChoiceField (forms.ModelChoiceField):
>    def label_from_instance(self,obj):
>        return obj.page_plaque
>
> page_plaque  = PagePlaqueModelChoiceField
> (queryset=WebPage.objects.filter(page_plaque!=''),
> empty_label='Choose',required=False, widget=forms.Select(attrs=
> {'class':'dropbox'}))
>
>
>
> this is not working and errors out with:
>
> 'bool' object is not iterable
>
>
> Is this possible and if so what am i doing wrong?  Can I pull a
> DISTINCT list of values for that field?
>
>
> >
>
The issue is the line: WebPage.objects.filter(page_plaque!='').  The
queryset syntax doens't use the != operator anywhere.  To do != operations
you need to instead do WebPage.objects.exclude(page_plaque='').

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to