Having referenced http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/, I set about in an attempt to make a dynamic form through a simple change to __init__, but not all is well...
My code is simply: .class RFSInputForm(forms.Form): . def __init__(self, rfs, *args, **kwargs): #test init to add add'tl field . super(RFSInputForm, self).__init__(self, *args, **kwargs) . self.fields['somefield'] = forms.CharField() which seems simple enough, but when the form is printed: .if __name__ == '__main__': . rfs = RFSInputForm('simple_age') . print rfs I get the error: .Traceback (most recent call last): . File "./process/forms.py", line 34, in <module> . print rfs . File "/Library/Python/2.5/site-packages/django/utils/encoding.py", line 30, in __str__ . return self.__unicode__().encode('utf-8') . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 94, in __unicode__ . return self.as_table() . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 190, in as_table . return self._html_output(u'<tr><th>%(label)s</th><td>%(errors)s% (field)s%(help_text)s</td></tr>', u'<tr><td .colspan="2">%s</td></ tr>', '</td></tr>', u'<br />%s', False) . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 139, in _html_output . top_errors = self.non_field_errors() # Errors that should be displayed above all fields. . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 206, in non_field_errors . return self.errors.get(NON_FIELD_ERRORS, self.error_class()) . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 111, in _get_errors . self.full_clean() . File "/Library/Python/2.5/site-packages/django/forms/forms.py", line 225, in full_clean . value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name)) . File "/Library/Python/2.5/site-packages/django/forms/widgets.py", line 170, in value_from_datadict . return data.get(name, None) .AttributeError: 'RFSInputForm' object has no attribute 'get' I'm hoping someone could enlighten me as to what the problem might be. I've distilled my experiment to the simplest possible instance, but the suggestion found at http://www.b-list.org/weblog/2008/nov/09/dynamic-forms/ does not seem to be working as advertised. Can anyone detect where I've gone wrong? Thanks, Alex. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---