completed add-book, deleted forms.py since it was not needed

parent 091d2e80
{% extends 'base.html' %}
{% block title %}Add New Book{% endblock %}
{% block heading %}
{% endblock %}
{% block text %}
<form method="post">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Save">
</form>
{% endblock %}
{% block content %}
hi
{% endblock %}
{%block hyperlinks%}
<ul>
{% for object in object_list %}
<li><a href="{{object.get_absolute_url}}">{{object.title}}</a></li>
{% endfor %}
<br></br>
<a href="/home">Home</a>
<a href="/authors">Authors</a>
</ul>
{%endblock%}
\ No newline at end of file
...@@ -18,9 +18,7 @@ I enjoy a plethora of genres. as long as the author imerses me in their world, t ...@@ -18,9 +18,7 @@ I enjoy a plethora of genres. as long as the author imerses me in their world, t
{%block hyperlinks%} {%block hyperlinks%}
<a href="/books">Books</a> <a href="/books">Books</a>
<a href="/authors">Authors</a> <a href="/authors">Authors</a>
{%endblock%} <br></br>
{%block hyperlinks%}
<a href="/books/add">Add Book</a> <a href="/books/add">Add Book</a>
<a href="/authors/add">Add Author</a> <a href="/authors/add">Add Author</a>
{%endblock%} {%endblock%}
\ No newline at end of file
from django.shortcuts import render from django.shortcuts import render
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.edit import CreateView, UpdateView #To be able to use CreateView & UpdateView
from .models import Author, Book from .models import Author, Book
# Create your views here. # Create your views here.
...@@ -34,10 +35,12 @@ class AuthorDetailsView(DetailView): ...@@ -34,10 +35,12 @@ class AuthorDetailsView(DetailView):
class AddBookView(ListView): class AddBookView(CreateView):
template_name = "bookshelf/add-book.html" model = Book
model = Author fields = '__all__'
template_name = 'bookshelf/add-book.html'
class AddAuthorView(ListView): class AddAuthorView(CreateView):
template_name = "bookshelf/add-author.html" model = Author
model = Author fields = '__all__'
\ No newline at end of file template_name = 'bookshelf/add-author.html'
\ No newline at end of file
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