How can I prevent a user from modifying a post that does not correspond to him? Example: a user enters to: www.localhost: 8080 / profile / number / emergency / update / 1 <- avoid that the auto-incremental post that the database has (the model) I can not modify to one that does not correspond to he.
Example of a view I have
view.py
def EmergenciaUpdate(request, emergencia_id):
instancia = get_object_or_404(Emergencia,id=emergencia_id)
form = EmergenciaUpdateForm(request.POST or None, instance=instancia)
if request.method == 'POST':
if form.is_valid():
form.save()
return redirect('emergencialista')
return render(request, 'app/emergenciaupdate.html', {'emergencia_update_form':form})
url.py
url(r'^perfil/numero/emergencia/update/(?P<emergencia_id>\d+)/$', EmergenciaUpdate, name='emergenciaupdate'),