Hi I have declared a model and the simple views I created are working.
Now I am trying to move to generic views. So I added in urls.py path('book2/<int:pk>/', views.DetailView.as_view(), name='detail'), And in views.py class DetailView(generic.DetailView): model = Book And the template is {% block content %} <h1>book List</h1> {% if object_list %} <ul> {% for book in object_list %} <li> {{ book.author }} </li> {% endfor %} </ul> {% else %} <p>There are no books in the library.</p> {% endif %} {% endblock %} For reference the models.py had been class Book(models.Model): author = models.CharField(max_length=70) But the result is "There are no books in the library". So it seems that the books list is not transferred to the template to be rendered. Could you help me understand where I have done wrong? Thank you -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0c7de55c-4923-447a-9bf0-0ea962ca3542%40googlegroups.com.