On 11/2/07, Simone Cittadini <[EMAIL PROTECTED]> wrote:
> I think I'm in need of a for dummy example here ...
>
> in the view code :
>
> def list_filters(request):
>     [...]
>     else:
>         form = FormFilters()
>         form.filter_name.choices = [(f.name, f.name) for f in
> Filter.objects.all()]
>         return render_to_response('list_filters.html', locals(),
> RequestContext(request, {}))
>
> gives :
>
> AttributeError - 'FormFilters' object has no attribute 'filter_name' ....

You're looking for form.fields['filter_name'].choices, there.

Alternatively:

    class FormFilters(forms.Form):
        filter_name = forms.ChoiceField()

        def __init__(self, *args, **kwargs):
            super(FormFilters, self).__init__(*args, **kwargs)
            self.fields['filter_name'].choices = [(f.name, f.name) for
f in Filter.objects.all()]

Jonathan.

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

Reply via email to