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 manage.py runserver I see the following error in console
File "C:\Users\....\locallibrary\catalog\urls.py", 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
urls.py 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'),
]
views.py 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 views.py file