Commit b9e8b471 authored by Jan Ericsson Ong Ang's avatar Jan Ericsson Ong Ang

fixed author and book for loops

parent 407bc54d
......@@ -5,9 +5,11 @@
{% block content %}
{% block header %}<h1>{{ nickname }}'s Favorite Authors:</h1>{% endblock %}
<br>
{% for author in authors %}
{% for author in author_data %}
<a href="/bookshelf/authors/{{ author.pk }}/details/">{{ author.first_name }} {{ author.last_name }}</a>
<br>
{% endfor %}
<br>
......
......@@ -5,9 +5,11 @@
{% block content %}
{% block header %}<h1>{{ nickname }}'s Favorite Books:</h1>{% endblock %}
<br>
{% for book in books %}
<a href="/bookshelf/books/{{ book.pk }}/details/"><p>{{ book.title }}</p></a>
{% for book in book_data %}
<a href="/bookshelf/books/{{ book.pk }}/details/">{{ book.title }}</a>
<br>
{% endfor %}
<br>
......
......@@ -12,18 +12,22 @@ def HomeView(request):
class AuthorView(ListView):
def get(self, request):
model = Author
return render(request, 'bookshelf/authors.html', {'nickname': 'Jan'})
author_data = Author.objects.all().values()
return render(request, 'bookshelf/authors.html', {'nickname': 'Jan', 'author_data': author_data})
class AuthorDetailView(DetailView):
model = Author
model_data = Author
template_name = 'bookshelf/author_details.html'
class BooksView(ListView):
def get(self, request):
model = Books
return render(request, 'bookshelf/books.html', {'nickname': 'Jan'})
book_data = Books.objects.all().values()
return render(request, 'bookshelf/books.html', {'nickname': 'Jan', 'book_data': book_data})
class BookDetailView(DetailView):
model = Books
model_data = Books
template_name = 'bookshelf/books_details.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