Commit 12ecffad authored by Brendan Fausto's avatar Brendan Fausto

Fixed errors in authors and books page, and set up forms for adding new books and authors

parent 798dcd12
from django.forms import ModelForm
from bookshelf.models import Books, Authors
class BookForm(ModelForm):
class Meta:
model = Books
fields = ['title','author','year_published','isbn','blurb']
class AuthorForm(ModelForm):
class Meta:
model = Books
fields = ['first_name','last_name','age','nationality','bio']
\ No newline at end of file
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ul> <ul>
{% for object in authors %} {% for object in authors %}
<li> <li>
<a href "{{ object.get_absolute_url }}">{{ object.first_name }} {{ object.last_name }} </a> <a href = "http://127.0.0.1:8000/authors/{{ object.get_absolute_url }}/details">{{ object.first_name }} {{ object.last_name }} </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<ul> <ul>
{% for object in books %} {% for object in books %}
<li> <li>
<a href "http://127.0.0.1:8000/books/{{object.pk}}"> {{ object.title }} </a> <a href = "http://127.0.0.1:8000/books/{{ object.get_absolute_url }}/details"> {{ object.title }} </a>
</li> </li>
{% endfor %} {% endfor %}
</ul> </ul>
......
...@@ -7,8 +7,8 @@ urlpatterns = [ ...@@ -7,8 +7,8 @@ urlpatterns = [
path('home', home_view, name='index'), path('home', home_view, name='index'),
path('books', BookListView.as_view(), name='book-list'), path('books', BookListView.as_view(), name='book-list'),
path('authors', AuthorListView.as_view(), name='author-list'), path('authors', AuthorListView.as_view(), name='author-list'),
path('books/<int:pk>', BookDetailView.as_view(), name='books-details'), path('books/<int:pk>/details', BookDetailView.as_view(), name='books-details'),
path('authors/<int:pk>', AuthorDetailView.as_view(), name='authors-details'), path('authors/<int:pk>/details', AuthorDetailView.as_view(), name='authors-details'),
] ]
app_name = "bookshelf" # for proper namespacing in urls, otherwise will result in errors app_name = "bookshelf" # for proper namespacing in urls, otherwise will result in errors
\ 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