Hi,
How can we dynamically add a fileField to the dynamic form. I tried
doing that using the following code but it is throwing errors.


from django import forms

class QuestionsForm(forms.Form):
    def __init__(self, questions,  *args, **kwargs):
        super(QuestionsForm, self).__init__(*args, **kwargs)
        for question in questions:
            if question.answer_type == 'textbox':
                self.fields['question_%d' % question.id] =
forms.CharField(widget = forms.Textarea( attrs={'rows':5, 'cols':60}))
            elif question.answer_type == 'file':
                self.fields['question_%d' % question.id] =
forms.FileField(upload_to='some_dir/')

    The error message that i'm getting is: init() got an unexpected
keyword argument ‘upload_to’

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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