title: Local Variable referenced before assignment
body: <p>I was wondering if you guys could help.  I'm trying to do a simple view where it sends the user to the client creation form, but I keep getting this error:</p>
  
  <blockquote>
    <p>local variable 'form' referenced before assignment</p>
  </blockquote>
  
  <p>Looking at my code, I can't see whats wrong.  </p>
  
  <pre><code>def add_client(request):
      user = request.user
      if request.method =='POST':
          form = AddClientForm(request.POST)
          if form.is_valid():
              client = form.save(commit=False)
              client.save()
              return HttpResponseRedirect('/')
          else:
              form = AddClientForm()
  
      return render_to_response('clients/addClient.html', { 'form': form, 'user': user, }, context_instance=RequestContext(request))
  </code></pre>
  
  <p>Anyone tell me where I went wrong?</p>