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> <!DOCTYPE html>
{% extends 'base.html' %} {% extends 'base.html' %}
{% block title %}This is the page title{% endblock %} {% block title %}My Favorite Books and Authors{% endblock %}
{% block content %} {% 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 %} {% endblock %}
from django.urls import path from django.urls import path
from .views import index, HomeView from .views import HomeView, BooksView, BookDetailsView, AuthorsView, AuthorDetailsView
urlpatterns = [ urlpatterns = [
path('', index, name='index'), #path('', index, name='index'),
path('home', HomeView.as_view(), name='home'), #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" app_name = "bookshelf"
...@@ -6,13 +6,36 @@ from django.views.generic.detail import DetailView ...@@ -6,13 +6,36 @@ from django.views.generic.detail import DetailView
from .models import Author, Books from .models import Author, Books
def index(request): #def index(request):
return HttpResponse('Hello World!') #return HttpResponse('Hello World!')
def HomeView(request):
class HomeView(View):
def get(self, request):
return render(request, 'bookshelf/home.html', {}) 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. # Create your views here.
...@@ -15,10 +15,12 @@ Including another URLconf ...@@ -15,10 +15,12 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import include, path from django.urls import include, path
from bookshelf.views import HomeView #from bookshelf.views import HomeView
urlpatterns = [ 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('bookshelf/', include('bookshelf.urls', namespace="bookshelf")),
path('', include('bookshelf.urls', namespace="basic")),
path('admin/', admin.site.urls), 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