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'
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.
Apologies for the late reply. I didn’t want to just keep asking questions without doing due diligence
Item1
Yes. In my views.py file I imported the ‘Book’ Model using
from .models import Book, Author, BookInstance, Genre
Item2
I’ve verified the finished files and they have the same content required until Part 6 (plus additional content)
Item 3
On checking Django documentation for Class-based generic views there is slight change in syntax for calling List & Detail Views compared to the tutorial in views.py file (although I doubt the change matters in this case)
In Django tutorial it is:
from django.views import generic
class BookListView(generic.ListView):
model = Book
In Django documentation it is:
from django.views.generic import ListView
class BookListView(ListView):
model = Book
In spite of trying the above hacks still seeing the same error
It’s a pity it still isn’t working after all this effort.
I agree. That shouldn’t make a difference. It just imports one level deeper and then uses ListView directly.
It’s possible that something fundamentally changed in newer Python/Django versions which makes the current tutorial code break. If you’re still interested in finding the cause of the problem you could use the complete code from GitHub in another folder and see if it works with a current version of Python/Django. If that fails it’s probably time to open an issue on GitHub to let someone update the code.
Maybe it’s generally a good idea to open an issue there with all the information you collected. Chances are the person updating the repo can push you in the right direction. As I initially said I know nothing about Python and it seems there’s no one else here knowledgeable about it either.