Re: obeying the DRY principle in views

2008-03-31 Thread msoulier
On Mar 31, 10:04 pm, Michael <[EMAIL PROTECTED]> wrote: > Not really a DRY issue moreover there is an easier logic to your code: Sad that I didn't see that. Thanks, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Group

Re: obeying the DRY principle in views

2008-03-31 Thread Michael
Not really a DRY issue moreover there is an easier logic to your code: if request.method == 'POST': form = MyForm(request.POST) if form.is_valid(): # make new model object and save return HttpResponseRedirect('/') else: form = MyForm(initial=data) return render_to_response('templa

obeying the DRY principle in views

2008-03-31 Thread msoulier
I find myself doing this a lot in view code if request.method == 'GET': form = MyForm(initial=data) return render_to_response('template.html', RequestContext(request, { 'foo': foo, 'bar': bar })) elif request.method == 'POST': form = MyForm(request.POST)