Appreciate assistance with Django Tutorial Part 6: Generic List and Detail Views run-time error

Hello Community,
Enjoying the Django tutorial very much and wishing this community a success in their learning journeys.

I would be happy if you can assist regarding the Django Tutorial Part 6: Generic List and Detail Views

When I run the final step as suggested here by running py runserver I see the following error in console

File "C:\Users\....\locallibrary\catalog\", line 5, in <module>
path('books/', views.BookListView.as_view(), name='books'),
AttributeError: module 'catalog.views' has no attribute 'BookListView'

Content from the respective files file

from django.urls import path
from . import views
urlpatterns = [
path('', views.index, name='index'),
path('books/', views.BookListView.as_view(), name='books'),
path('book/<int:pk>', views.BookDetailView.as_view(), name='book-detail'),
] file (Partial Content)

 from django.views import generic

class BookListView(generic.ListView):
    model = Book
class BookDetailView(generic.DetailView):
    model = Book

I also have the book_list.html and book_details.html files created as mentioned and placed in the correct path locallibrary\catalog\templates\catalog

As you can see above there is clearly a BookListView defined in file

Hi @iambhargav and welcome to the community :wave:

I don’t have any experience with Django, but the complete tutorial code is on MDN’s GitHub repo. Maybe you can use it to find the problem.

A shot in the dark:
Is the model you used define/imported? If there’s a problem with it maybe the view couldn’t be created in the first place.

Sorry, that I can’t give you a better answer :frowning:

Have a nice weekend,

Hello @mikoMK :wave: ,

Thanks for your quick reply. The model used is imported (from django.db import models). I will verify if there were any updates to/issues with it. I can check the complete code on Github but I’m guessing the related files (views, urls) will be much further along in the tutorial so some trial and error required to determine the exact file contents required at this stage for a successful execution.

Once again appreciate your enthusiasm,

Have a long weekend,

Yeah, those are the finished files from the end of the whole tutorial I guess.

What I meant was: Do you import the actual “Book” model in your “” with from .models import Book?