title: Django views, logic, and skinny controllers
body: <p>So, I have a Django view, which is based on <code>django.views.generic.View</code>, which accepts only <code>POST</code> requests. It takes basic calls in an <code>application/x-www-form-urlencoded</code> format, parses them, and then responds as appropriate. I realise this is failing on the idea of skinny controller, fat model, but I'm not sure as to the best location to place the following logic, as it is related to the view, rather than specifically to the underlying model.</p>
  
  <p>At present, the view handles some logic to create new subscriptions:</p>
  
  <pre><code>class ExampleView(View):
  
     def post(self, request, *args, **kwargs):
          mode = request.POST.get('mode')
  
          if not mode:
              return HttpResponse('mode required', status=400)
  
          if mode == 'subscribe':
              if not request.POST.get('topic'):
                  return HttpResponse('topic required', status=400)
  
              if not [ another required argument ]:
                  and so on ...
  
              [ If we're ready to roll, create a Subscription object ]
  
              return HttpResponse('Subscribed', status=200)
  </code></pre>
  
  <p>So, this appears to me like putting the logic in the wrong layer. Where would be the best place to process what is being passed to the View, and to generate/fail to generate Subscription objects as appropriate. </p>
  
  <p>Should the processing of the provided data happen on the Subscription object, which then returns HttpResponses to the view? Or should it just return status' and messages, which are then relayed to the user by the view creating the correct HttpResponse object?</p>