Detail View by ID in Django - 14
Once the list view with pagination has been defined, we now move on to the detail page:
mystore\elements\templates\elements\detail.html
{% extends "base.html" %}
{% block content %}
<div class="card">
<div class="card-header">
<h1>{{ element.title }}</h1>
</div>
<div class="card-body">
<div>
{{element.description}}
</div>
<div>
{{element.content}}
</div>
</div>
</div>
{% endblock %}
As you can see, it is a simple template with the details of the publication and it is processed from the view:
def detail(request, pk):
element = Element.objects.get(id=pk)
return render(request,'elements/detail.html',
{'element': element }