image 2
image 1

DETAIL VIEW

The DetailView allows us to get the details of a single object, while with the Generic Display Views ListView we get the details of a list of objects. They are very comfortable because in addition to being particularly performing they are also easy to implement. Let’s go to the views.py file and implement a DetailView.

DetailView

After specifying the class that inherits from DetailView, you need to specify the model and template name. As for the latter, we will use the existing articoloDetail.html. We then go to manage the class in the file urls.py.

urls.py

LIST VIEW

ListView

This time we have specified a new HTML file, let’s see how we implemented it listaArticoli.html.

List Article

We also need to modify the urls.py file so that we can reach the new HTML page. Then we go to the browser at the specified address and verify that it works.

urls.py
List Article

LINKS TO PREVIOUS POST

PREVIOUS POST LINKS

LINK TO THE CODE ON GITHUB

GITHUB