Commit c5c3a554 authored by Brendan Fausto's avatar Brendan Fausto

Added templates for adding data, modified views to accomodate

parent 12ecffad
{% extends 'base.html' %}
{% block title %}
Add Author to Bookshelf
{% endblock %}
{% block header %}
<h1>Add New Author</h1>
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>{{ field.label }} has the following errors:</p>
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form method = "POST">
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Save">
</form>
<p>
<a href = "http://127.0.0.1:8000/home">Home</a>
<a href = "http://127.0.0.1:8000/books">Books</a>
<a href = "http://127.0.0.1:8000/authors">Authors</a>
</p>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% block title %}
Add Book to Bookshelf
{% endblock %}
{% block header %}
<h1>Add New Book</h1>
{% endblock %}
{% block content %}
{{ form.non_field_errors }}
{% for field in form %}
{% if field.errors %}
<p>{{ field.label }} has the following errors:</p>
<ul>
{% for error in field.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
{% endif %}
{% endfor %}
<form method = "POST">
{% csrf_token %}
{{ form.as_p }}
<input type = "submit" value = "Save">
</form>
<p>
<a href = "http://127.0.0.1:8000/home">Home</a>
<a href = "http://127.0.0.1:8000/authors">Authors</a>
</p>
{% endblock %}
\ No newline at end of file
...@@ -3,6 +3,7 @@ from django.views import View ...@@ -3,6 +3,7 @@ from django.views import View
from django.views.generic.detail import DetailView from django.views.generic.detail import DetailView
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.shortcuts import get_object_or_404 from django.shortcuts import get_object_or_404
from django.views.generic.edit import CreateView, UpdateView
from .models import Books, Authors from .models import Books, Authors
...@@ -29,8 +30,21 @@ class BookDetailView(DetailView): ...@@ -29,8 +30,21 @@ class BookDetailView(DetailView):
model = Books model = Books
template_name = 'bookshelf/books_details.html' template_name = 'bookshelf/books_details.html'
def get(self, request, *args, **kwargs):
print("BooksDetailView is being called")
return super().get(request, *args, **kwargs)
class AuthorDetailView(DetailView): class AuthorDetailView(DetailView):
model = Authors model = Authors
template_name = 'bookshelf/authors_details.html' template_name = 'bookshelf/authors_details.html'
class BookCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'add-book.html'
class AuthorCreateView(CreateView):
model = Books
fields = '__all__'
template_name = 'add-book.html'
# Create your views here. # 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