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
{%block hyperlinks%}
<a href="/books">Books</a>
<a href="/authors">Authors</a>
{%endblock%}
{%block hyperlinks%}
<br></br>
<a href="/books/add">Add Book</a>
<a href="/authors/add">Add Author</a>
{%endblock%}
\ No newline at end of file
from django.shortcuts import render
from django.views.generic.list import ListView
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
# Create your views here.
......@@ -34,10 +35,12 @@ class AuthorDetailsView(DetailView):
class AddBookView(ListView):
template_name = "bookshelf/add-book.html"
model = Author
class AddBookView(CreateView):
model = Book
fields = '__all__'
template_name = 'bookshelf/add-book.html'
class AddAuthorView(ListView):
template_name = "bookshelf/add-author.html"
model = Author
\ No newline at end of file
class AddAuthorView(CreateView):
model = Author
fields = '__all__'
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