Just use "initial" keyword on creation form
class myForm(forms.Form):
    test = forms.CharField(label = _('test'), max_length=255, required =
True)
....
myForm(initial = {'test': 'test string'}).

If you use form that generated from model:
class myForm(forms.Form):

  class Meta:
    model = myModel
...
myForm(initial = myModel(var1 = 'qq' )).

On Wed, Nov 18, 2009 at 4:19 AM, Nick Arnett <nick.arn...@gmail.com> wrote:

> I can't see to figure out how to do something fairly simple - set the
> initial value of a model form field at runtime.  The form is a simple set of
> radio buttons that lets the user choose which project to work on.  I'm
> storing the selection in a session variable and that's working fine.  What I
> can't figure out, though it seems like it must be staring me in the face, is
> how to set the current choice that's stored in the session variable, so that
> when the form is displayed, the current project's radio button is selected.
>
> I've created custom forms and set initial values... but how do I do that
> with a model form?  Or should it be a custom form to do that?
>
> Thanks in advance,
>
> Nick
>
> --
> 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<django-users%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=.
>

--

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=.


Reply via email to