def reclaim(request): if request.method == 'POST': form = ComplaintForm(request.POST,request.FILES) if form.is_valid(): obj = Complaint(**form.cleaned_data) obj.save() #return HttpResponseRedirect('/inscricao/%d/' % obj.pk) return HttpResponseRedirect('/reclamacoes') else : return render(request, 'complaints/complaint_form.html', { 'form': form}) else: return render(request,'complaints/complaint_form.html',{'form': ComplaintForm()})
def ler(request,nr_reclamacao): complaint = get_object_or_404(Complaint,pk=nr_reclamacao) complaint.lida = True complaint.save() form = ComplaintForm(instance=complaint) if request.method=="POST": form = ComplaintForm(request.POST,request.FILES,instance=complaint) if form.is_valid(): complaint = form.save(commit=False) complaint.save() form.save_m2m() return HttpResponseRedirect('/reclamacoes') return render_to_response("complaints/ler.html",{'form':form}, context_instance=RequestContext(request))