Commit f316a682 authored by Eldon Dagdag's avatar Eldon Dagdag

Add/Update features for Book/Author models created

parent c1b179a7
from django import forms
from .models import Book, Author
class BookForm(forms.ModelForm):
class Meta:
model = Book
fields = '__all__'
class AuthorForm(forms.ModelForm):
class Meta:
model = Author
fields = '__all__'
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
\ No newline at end of file
{% block title %}Add New Author{% endblock %}
{% block content %}
<br>
<form method="post">
{% csrf_token %}
{% for field in form %}
{{ field.label }}: {{ field }}<br>
{% endfor %}
<input type="submit" value="Add Author">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
\ No newline at end of file
{% block title %}Add New Book{% endblock %}
{% block content %}
<br>
<form method="post">
{% csrf_token %}
{% for field in form %}
{{ field.label }}: {{ field }}<br>
{% endfor %}
<input type="submit" value="Add Book">
</form>
{% endblock %}
\ No newline at end of file
......@@ -9,6 +9,8 @@
<h3>Nationality: {{ object.nationality }}</h3>
<h3>Biography: {{ object.bio }}</h3>
<a href="/bookshelf/authors/{{ object.pk }}/edit/">Edit Author</a>
<h2>Books by {{ object.first_name }} {{ object.last_name }} I love:</h2>
<ul>
{% for book in object.books.all %}
......
......@@ -10,6 +10,7 @@
<h3>Published in {{ object.year_published }}</h3>
<h3>ISBN: {{ object.ISBN }}</h3>
<h3>"{{ object.blurb }}"</h3>
<a href="/bookshelf/books/{{ object.pk }}/edit/">Edit Book</a>
</body>
<br>
<div class="container space-evenly">
......
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
\ No newline at end of file
{% block title %}Edit Author{% endblock %}
{% block content %}
<br>
<form method="post">
{% csrf_token %}
{% for field in form %}
{{ field.label }}: {{ field }}<br>
{% endfor %}
<input type="submit" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
{% extends 'base.html' %}
{% load static %}
{% block title %} {{ object.first_name }} {{ object.last_name }}{% endblock %}
{% block content %}
\ No newline at end of file
{% block title %}Edit Book{% endblock %}
{% block content %}
<br>
<form method="post">
{% csrf_token %}
{% for field in form %}
{{ field.label }}: {{ field }}<br>
{% endfor %}
<input type="submit" value="Save Changes">
</form>
{% endblock %}
\ No newline at end of file
......@@ -8,7 +8,8 @@
<div class="container space-evenly">
<a href="/bookshelf/books/">Books</a>
<a href="/bookshelf/authors/">Authors</a>
<br>
</div>
<div class="container space-evenly">
<a href="/bookshelf/books/add/">Add Book</a>
<a href="/bookshelf/authors/add/">Add Author</a>
</div>
......
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