I was wondering if you guys could help. I am trying to make a simple view where it sends the user to the client creation form, but I keep getting this error:
local variable "form" specified before assignment
Looking at my code, I do not see what is wrong.
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))
Will someone tell me where I was wrong?
source share