Set model form initial value?

2009-11-17 Thread Nick Arnett
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'

Re: Set model form initial value?

2009-11-18 Thread Ilya Polosuhin
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 = myMod

Re: Set model form initial value?

2009-11-18 Thread Nick Arnett
On Wed, Nov 18, 2009 at 2:01 AM, Ilya Polosuhin wrote: > 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