Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Merrick
Found the problem, thanks again for all of the help. It turns out you have to define the extra field above def __init__(self, *args, **kw) as in: forms.py class SomeForm(ModelForm): checkbox = forms.BooleanField(required=False, widget=forms.CheckboxInput(), label='some label')

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Daniel Roseman
On Apr 7, 6:19 pm, Merrick wrote: > I appreciate all of the help, I was actually showing both Daniel and > Raj that their suggestions have been tried to no result. To answer > your question, look up at Raj's suggestion. My code before and after > trying the suggestions above,

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Merrick
I appreciate all of the help, I was actually showing both Daniel and Raj that their suggestions have been tried to no result. To answer your question, look up at Raj's suggestion. My code before and after trying the suggestions above, is to have message defined outside of meta. Do you have a

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Tom Evans
On Wed, Apr 7, 2010 at 5:30 PM, Merrick wrote: > Thank you. > > I'll be more specific, here is what I have: > > views.py > - > ... > if request.method == 'POST': >    some_form = SomeForm(data = request.POST, request=request, > instance=somemodel) >    ... >    if

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Merrick
Thank you. I'll be more specific, here is what I have: views.py - ... if request.method == 'POST': some_form = SomeForm(data = request.POST, request=request, instance=somemodel) ... if some_form.is_valid(): some_form_update = some_form.save(commit=False)

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread Daniel Roseman
On Apr 7, 4:05 am, Merrick wrote: > I added a checkbox form field to my template, and I even tried to add > it in my forms.py and then in my views.py I check for it like so: > > if form.cleaned_data['checkbox_field']: >   code to send email... > > But when I submit the form I

Re: how to add a field to a model form when the field is not in the model

2010-04-07 Thread raj
On Apr 7, 8:05 am, Merrick wrote: > How should I go about adding a field to a model form > when the field is not part of the model? Define a Custom ModelForm by specifying model in Meta and declare the required addnl field there. (check-box means boolean, right?). Now set

how to add a field to a model form when the field is not in the model

2010-04-06 Thread Merrick
I added a checkbox form field to my template, and I even tried to add it in my forms.py and then in my views.py I check for it like so: if form.cleaned_data['checkbox_field']: code to send email... But when I submit the form I get a KeyError. How should I go about adding a field to a model