Initialized views and urls for the .html files

parent 747fb85a
from django.urls import path
from .views import index
from .views import home_view, BooksView, BooksDetailView, AuthorView, AuthorDetailView
urlpatterns = [
path('', index, name='index'),
path('', home_view, name='home'),
path('books', BooksView.as_view(), name='books'),
path('books/<int:pk>/details/', BooksDetailView.as_view(), name='book-details'),
path('author', AuthorView.as_view(), name='author'),
path('author/<int:pk>/details/', AuthorDetailView.as_view(), name='author-details'),
]
# This might be needed depending on your Django version
app_name = "bookshelf"
\ No newline at end of file
from django.shortcuts import render
from django.views import View
from django.http import HttpResponse
def index(request):
return HttpResponse('Hello World! This came from the index view')
def home_view(request):
return render(request, 'bookshelf/home.html', {})
class HomeView(View):
def get(self,request):
return render(request, 'bookshelf/home.html', {})
class BooksView(View):
def get(self,request):
return render(request, 'bookshelf/books.html', {})
class BooksDetailView(View):
def get(self,request):
return render(request, 'bookshelf/books_detail.html', {})
class AuthorView(View):
def get(self,request):
return render(request, 'bookshelf/author.html', {})
class AuthorDetailView(View):
def get(self,request):
return render(request, 'bookshelf/author_details.html', {})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment