Commit f4799a69 authored by Joei Yucoco's avatar Joei Yucoco

created generic bookshelf templates and configured their urls

- templates: home, books, etc.
- will clean up comments later
parent 4d0e0d0e
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}My Favorite Books and Authors{% endblock %}
{% block content %}
<h1>Hello author details</h1>
{% endblock %}
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}My Favorite Books and Authors{% endblock %}
{% block content %}
<h1>Hello authors</h1>
{% endblock %}
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}My Favorite Books and Authors{% endblock %}
{% block content %}
<h1>Hello book details</h1>
{% endblock %}
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}My Favorite Books and Authors{% endblock %}
{% block content %}
<h1>Hello books</h1>
{% endblock %}
<!DOCTYPE html>
{% extends 'base.html' %}
{% block title %}This is the page title{% endblock %}
{% block title %}My Favorite Books and Authors{% endblock %}
{% block content %}
<h1>Hello World. This is the content</h1>
<h1>Welcome to Joei's Database of</h1>
<h1>Favorite Books and Authors</h1>
<h3>I like books that look interesting...</h3>
{% endblock %}
from django.urls import path
from .views import index, HomeView
from .views import HomeView, BooksView, BookDetailsView, AuthorsView, AuthorDetailsView
urlpatterns = [
path('', index, name='index'),
path('home', HomeView.as_view(), name='home'),
#path('', index, name='index'),
#path('home', HomeView.as_view(), name='home'),
path('home/', HomeView, name='home'),
path('books/', BooksView.as_view(), name='books-list'),
path('books/<int:pk>/details/', BookDetailsView.as_view(), name='books-detail'),
path('authors/', AuthorsView.as_view(), name='authors-list'),
path('authors/<int:pk>/details/', AuthorDetailsView.as_view(), name='authors-detail'),
]
app_name = "bookshelf"
......@@ -6,13 +6,36 @@ from django.views.generic.detail import DetailView
from .models import Author, Books
def index(request):
return HttpResponse('Hello World!')
#def index(request):
#return HttpResponse('Hello World!')
class HomeView(View):
def get(self, request):
def HomeView(request):
return render(request, 'bookshelf/home.html', {})
class BooksView(ListView):
model = Books
template_name = 'bookshelf/books.html'
class BookDetailsView(DetailView):
model = Books
template_name = 'bookshelf/book_details.html'
class AuthorsView(ListView):
model = Author
template_name = 'bookshelf/authors.html'
class AuthorDetailsView(DetailView):
model = Author
template_name = 'bookshelf/author_details.html'
#class HomeView(View):
#def get(self, request):
#return render(request, 'bookshelf/home.html', {})
# Create your views here.
......@@ -15,10 +15,12 @@ Including another URLconf
"""
from django.contrib import admin
from django.urls import include, path
from bookshelf.views import HomeView
#from bookshelf.views import HomeView
urlpatterns = [
path('home/', HomeView.as_view(), name='home'),
#path('home/', include('bookshelf.urls', namespace="home")),
#path('home/', HomeView.as_view(), name='home'),
path('bookshelf/', include('bookshelf.urls', namespace="bookshelf")),
path('', include('bookshelf.urls', namespace="basic")),
path('admin/', admin.site.urls),
]
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