Adrian Holovaty wrote:

> Which problem did you have with the prefix parameter? Was it just a
> problem of the patch not applying correctly, or was there some sort of
> bug?

The patch is ok and I don't think it's a bug: I was trying to find the
best way to implement a form with dynamic choices.

This code works with r4193 (but doesn't validate request.POST):

class OrderForm(forms.Form):
    articles = forms.MultipleChoiceField()
    def __init__(self, article_list, data=None):
        self['articles'].field.choices = article_list
        self['articles'].field.widget.choices = article_list
        super(OrderForm, self).__init__(data)

But from r4194 it causes an error:
Exception Type:         AttributeError
Exception Value:        '__init__' object has no attribute 'prefix'
Exception Location:
        /usr/lib/python2.4/site-packages/django/newforms/forms.py in
add_prefix, line 83


I have to postpone the two rows after the super __init__ call:

    def __init__(self, article_list, data=None):
        super(OrderForm, self).__init__(data)
        self['articles'].field.choices = article_list
        self['articles'].field.widget.choices = article_list

The second form seems to work but I don't know if there is a
better/cleaner way to get that result.
I'm sorry but my understanding of Django (and Python as well) is quite
limited.

Massimiliano


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to