Commit 0a3547f4 authored by Julia Anishka's avatar Julia Anishka

added homepage view

parent 7a55e49d
...@@ -16,7 +16,7 @@ class Author(models.Model): ...@@ -16,7 +16,7 @@ class Author(models.Model):
def verify_ISBN(value): def verify_ISBN(value):
if value.isdigit() == False: if value.isdigit() == False:
raise ValidationError('ISBN must only be integers.') raise ValidationError('ISBN must only be integers.')
if value != 13: if int(len(value)) != 13:
raise ValidationError('ISBN must be a 13 digit number.') raise ValidationError('ISBN must be a 13 digit number.')
def verify_wordCount(value): def verify_wordCount(value):
......
{% extends 'base.html' %} {% extends 'base.html' %}
{% block content %}
<h2><center> Welcome to Nisha's Database of <br> Favorite Books and Authors! </center></h2>
<p> The genres I usually enjoy include mystery, romance, and fantasy. From narratives
that revolve around crimes to supernatural elements in a fictional world, I find each
scene interesting. I enjoyed books written by J.K Rowling, specifically, Harry Potter due
to her intricate plotlines. Another favorite author is Taylor Jenkins Reid because of her
emotional and engaging storytelling. The characters in her book are deeply relatable and
she's able to move her readers through genuine dialogues.
</p>
{% block body %} {% block body %}
<h1> My Favorite Books & Authors </h1>
<h3><center> Welcome to Nisha's Database of <br> Favorite Books and Authors! </center></h3>
<p> The genres I usually enjoy include mystery, romance, and fantasy. From narratives
that revolve around crimes to supernatural elements in a fictional world, I find each
scene interesting. I enjoyed books written by J.K Rowling, specifically, Harry Potter due
to her intricate plotlines. Another favorite author is Taylor Jenkins Reid because of her
emotional and engaging storytelling. The characters in her book are deeply relatable and
she's able to move her readers through genuine dialogues.
</p>
<h5> <a href="{% url 'books' %}"> Books </a> <a href="{% url 'authors'}"> Authors </a></h5>
{% endblock %} {% endblock %}
\ No newline at end of file
...@@ -3,7 +3,8 @@ from django.urls import path ...@@ -3,7 +3,8 @@ from django.urls import path
from . import views from . import views
urlpatterns = [ urlpatterns = [
path('', views.index, name='index') path('home', views.homepage_view, name='home')
path('books', BooksView.as_view(), name='books')
] ]
......
from django.shortcuts import render from django.shortcuts import render
from django.http import HttpResponse
from django.views import View
from .models import Author, Books
def homepage_view(request):
authors = Author.objects.all()
books = Books.author.all()
context = {
'authors': authors,
'books': books
}
return render(request, 'home.html', context)
# Create your views here.
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