I'm following django 2.1 tutorial, based on this link https://docs.djangoproject.com/en/2.1/topics/class-based-views/ Here is my Code for books/urls.py
from django.urls import path, re_path
from . import views
from book.views import BookListView
app_name = 'book'
urlpatterns = [
path('', views.index, name = 'index')
path('list/', BookListView.as_view(template_name="media/templates/book/book_list.html")),
]
Below is my book/views.py
from django.shortcuts import render
from .models import Author, Book, BookInstance, Genre
from django.views.generic import ListView
def index(request):
num_books = Book.objects.all().count()
num_instances = BookInstance.objects.all().count()
num_instances_available = BookInstance.objects.filter(status__exact = 'a').count()
num_author = Author.objects.count()
context = {
'num_books' : num_books,
'num_instances' : num_instances,
'num_instances_available' : num_instances_available,
'num_author' : num_author,
}
return render(request, 'book/index.html', context)
class BookListView(ListView):
model = Book
Error I'm getting is
File "E:\DJango\mysite\book\urls.py", line 8 path('list/', BookListView.as_view(template_name="media/templates/book/book_list.html")),
^ SyntaxError: invalid syntax