Commit fd8e27b8 authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

Edits on urls.py

parent 690adcb5
......@@ -4,9 +4,9 @@ from .views import HomeView, AuthorView, AuthorDetailView, BooksView, BookDetail
# url for bookshelf
urlpatterns = [
path('', HomeView.as_view(), name='homepage'),
path('author', AuthorView.as_view(), name='author-list'),
path('author/<int:pk>', AuthorDetailView.as_view(), name='author-detail'),
path('books', BooksView.as_view(), name='books-list'),
path('books/<int:pk>', BookDetailView.as_view(), name='books-detail'),
path('', HomeView.as_view(), name='home'),
path('author/', AuthorView.as_view(), name='author'),
path('author/<int:pk>/', AuthorDetailView.as_view(), name='author-detail'),
path('books/', BooksView.as_view(), name='books'),
path('books/<int:pk>/', BookDetailView.as_view(), name='books-detail'),
]
\ No newline at end of file
......@@ -8,11 +8,11 @@ from .models import Author, Books
class HomeView(View):
def get(self, request):
return render(request, 'bookshelf/home.html', {'nickname': 'Jan'})
return render(request, 'bookshelf/templates/bookshelf/home.html', {'nickname': 'Jan'})
class AuthorView(ListView):
model = Author
template_name = 'bookshelf/author.html'
template_name = 'bookshelf/templates/bookshelf/author.html'
class AuthorDetailView(DetailView):
model = Author
......
......@@ -11,6 +11,7 @@ https://docs.djangoproject.com/en/4.1/ref/settings/
"""
from pathlib import Path
import os
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent
......@@ -116,7 +117,8 @@ USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.1/howto/static-files/
STATIC_URL = '/static/'
STATIC_URL = '/templates/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'templates')]
# Default primary key field type
# https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field
......
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