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')

    def __init__(self, *args, **kw):
        self.request = kw.pop('request')
        super(SomeForm, self).__init__(*args, **kw)




On Apr 7, 10:19 am, Merrick <merr...@gmail.com> 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, is to have message defined outside of
> meta.
>
> Do you have a suggestion aside from that?
>
> Thanks.
>
> On Apr 7, 10:07 am, Tom Evans <tevans...@googlemail.com> wrote:
>
>
>
> > On Wed, Apr 7, 2010 at 5:30 PM, Merrick <merr...@gmail.com> 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 some_form.is_valid():
> > >        some_form_update = some_form.save(commit=False)
> > >        if some_form.cleaned_data['checkbox']:
> > >            #do something
> > >            ...
> > >    return HttpResponseRedirect(reverse('app.views.somemodel_detail',
> > > args=(somemodel.key_id,)))
>
> > > else:
> > >    some_form = SomeForm(request=request, instance = somemodel)
>
> > >    return render_to_response("template.html", {'some_form':
> > > some_form}, context_instance=RequestContext(request))
>
> > > forms.py
> > > ------------
> > > class SomeForm(ModelForm):
>
> > >   def __init__(self, *args, **kw):
> > >        self.request = kw.pop('request')
> > >        super(SomeForm, self).__init__(*args, **kw)
>
> > >   #I originally had checkbox outside of meta but have tested both
> > > ways now
> > >   #checkbox = forms.BooleanField(required=False, label='Checkbox')
>
> > >    class Meta:
> > >        model = SomeModel
> > >        checkbox = forms.BooleanField(required=False,
> > > label='Checkbox')
>
> > This is wrong. Where did you see to put fields in a form in the Meta class?
>
> > class FooForm(forms.ModelForm):
> >   this_field_aint_on_the_model = forms.CharField(max_length=64)
> >   class Meta:
> >     model = Foo
>
> > Tom

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

Reply via email to