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