I have a project where I need to dynamically set the default values for 
a form field. I have come up with the following solution, but wanted to 
check here to see if anyone saw any problems with it:

----MyForm----
class MyForm(forms.Form):
        user_name = forms.CharField(min_length=1, max_length=60)

        
        def set_initial(self, property, value):
                self.fields[property].initial = value
        #end set_initial
--------------

form = MyForm()
form.set_initial('user_name', "John Doe")

-------

Anyone see any issues with that approach? Or am I missing something 
already built in?

mike chambers

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