Commit e3dc6a99 authored by Star Neptune R. Sy's avatar Star Neptune R. Sy

front end of add-book.html is done

parent d8309378
......@@ -32,3 +32,6 @@ class Book(models.Model):
def get_absolute_url(self):
return self.pk
def getYearPublished(self):
return self.year_published.year
\ No newline at end of file
{% extends 'base.html '%}
{% block title %} Add new Author {% endblock %}
{% block content %}
<form action="/" method="post">
{% csrf_token %}
<label for="title">Title:</label>
<input type="text" id="textField" name="title"><br><br>
<label for="author">Author:</label>
<select id="selectField" name='author'>
{% for author in object_list %}
<option value={{ author }}>{{ author }}</option>
{% endfor %}
</select>
<label for="publisher">Publisher:</label>
<input type="text" id="textField" name="publisher"><br><br>
<label for="yearPublished">Year published:</label>
<input type="date" id="dateField" name="yearPublished"><br><br>
<label for="ISBN">ISBN:</label>
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<input type="text" id="textField" name="blurb"><br><br>
<input type="submit" id="submitButton" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html '%}
{% block title %} Add new book {% endblock %}
{% block content %}
<form action="/" method="post">
{% csrf_token %}
<label for="title">Title:</label>
<input type="text" id="textField" name="title"><br><br>
<label for="author">Author:</label>
<select id="selectField" name='author'>
{% for author in object_list %}
<option value={{ author }}>{{ author }}</option>
{% endfor %}
</select>
<label for="publisher">Publisher:</label>
<input type="text" id="textField" name="publisher"><br><br>
<label for="yearPublished">Year published:</label>
<input type="date" id="dateField" name="yearPublished"><br><br>
<label for="ISBN">ISBN:</label>
<input type="text" id="textField" name="ISBN"><br><br>
<label for="blurb">Blurb:</label>
<input type="text" id="textField" name="blurb"><br><br>
<input type="submit" id="submitButton" value="Submit">
</form>
{% endblock %}
\ No newline at end of file
......@@ -5,10 +5,13 @@
{% block additional %} Welcome to Neptune's database of favorite books and authors {% endblock %}
{% block content %}
<p>My taste in books are very random and usually done in the spur of the moment. I cannot commit to a series. </p>
<p> My taste in books are very random and usually done in the spur of the moment. I cannot commit to a series. </p>
<div>
<a class="navBtn" href="/books">Books</a>
<a class="navBtn" href="/authors"> Authors</a>
<br>
<a class="navBtn" href="/books/add">Add Book</a>
<!--<a class="navBtn" href="/authors">Add Author</a>-->
</div>
{% endblock %}
# bookshelf/urls.py
from django.urls import path
from .views import (homeView, BooksView, BooksDetail, AuthorView, AuthorDetail)
from .views import (homeView, BooksView, BooksAddView, BooksDetail, AuthorView, AuthorDetail)
from django.conf.urls.static import static
urlpatterns = [
......@@ -9,6 +9,9 @@ urlpatterns = [
path('books/<int:pk>/details/', BooksDetail.as_view(), name="book_details"),
path('authors/', AuthorView.as_view(), name="authors"),
path('authors/<int:pk>/details/', AuthorDetail.as_view(), name="author_details"),
#path for the forms that add
path('books/add', BooksAddView.as_view(), name='add_books'),
#path('authors/add'),
]
# This might be needed, depending on your Django version
......
......@@ -12,6 +12,11 @@ class BooksView(ListView):
template_name = "bookshelf/books.html"
class BooksAddView(ListView):
model = Author
template_name = "bookshelf/add-book.html"
class BooksDetail(DetailView):
model = Book
template_name = "bookshelf/book_detais.html"
......@@ -21,6 +26,10 @@ class AuthorView(ListView):
model=Author
template_name = "bookshelf/authors.html"
class AuthorAddView(ListView):
model = Book
template_name = "bookshelf/add-author.html"
class AuthorDetail(DetailView):
model=Author
......
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