I hope you can help me, I am trying to see information from the database but without moving the url.
When I access the list I get, for example, a list of books and when I click on the details of the book, I enter it in detail, however when I enter that page, it has the id of the database of the model.
Is there a way to be able to access without the URL moving?
I hope you can help me or give me some examples
urls:
url(r'^detalle/(?P<pk>[0-9]+)/$', views.detalle_id, name="detalle_id"),
url(r'^detalle/(?P<nombre>.*)/$', views.detalle_nombre),
views:
def detalle_id(request, pk):
detalle = Pregunta.objects.get(pk=pk)
Pregunta.objects.filter(id=pk).update(comentario='1')
return render(request, 'detalle.html', {'detalle': detalle})
def detalle_nombre(request, nombre):
detalle = Pregunta.objects.get(nombre=nombre)
return render(request, 'detalle.html', {'detalle': detalle})
def lista(request):
listadb = Pregunta.objects.all()
return render(request, 'lista.html', {'listadb':listadb})
I hope you can help me or give me some examples, Thanks!