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