fixed some templating issues
This commit is contained in:
parent
f13132d0c7
commit
5a83ccfc07
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -7,6 +7,7 @@
|
||||
# Feel free to rename the models, but don't rename db_table values or field names.
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
from django.utils.functional import cached_property
|
||||
|
||||
|
||||
class Author(models.Model):
|
||||
@ -224,9 +225,9 @@ class Book(models.Model):
|
||||
through='BookRatingLink',
|
||||
through_fields=('book', 'rating'))
|
||||
|
||||
@property
|
||||
@cached_property
|
||||
def rating(self):
|
||||
return self.rating.first()
|
||||
return self.ratings.first()
|
||||
|
||||
def get_absolute_url(self):
|
||||
"""Returns the url to access a particular instance of MyModelName."""
|
||||
|
@ -79,7 +79,7 @@
|
||||
</ul>
|
||||
<ul id="dropdown-tags" class="dropdown-content">
|
||||
{% for tag in unique_tags %}
|
||||
<li><a href="{{tag.get_absolute_url}}">{{tag}}</a></li>
|
||||
<li><a href="{{tag.get_absolute_url}}">{{tag}} ({{tag.num_books}})</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
@ -113,7 +113,8 @@
|
||||
<p>You don't have permission to view this.</p>
|
||||
</div>
|
||||
<div class="card-action center">
|
||||
<a class="waves-effect waves-light btn-large green accent-4" href="{% url 'login'%}?next={{request.path}}">Login</a>
|
||||
<a class="waves-effect waves-light btn-large green accent-4"
|
||||
href="{% url 'login'%}?next={{request.path}}">Login</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -17,7 +17,8 @@
|
||||
<tr>
|
||||
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
||||
<td>{{book.author_sort}}</td>
|
||||
<td> {% for rating in book.ratings.all %}
|
||||
<td>
|
||||
{% for rating in book.ratings.all %}
|
||||
{{rating}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
@ -17,9 +17,8 @@
|
||||
<tr>
|
||||
<td><a href="{{ book.get_absolute_url }}">{{ book.title }}</a></td>
|
||||
<td>{{book.author_sort}}</td>
|
||||
<td> {% for rating in book.rating.all %}
|
||||
<td>
|
||||
{{rating}}
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
{% for tag in book.tags.all %}
|
||||
|
@ -22,7 +22,7 @@
|
||||
{% endfor %}
|
||||
</td>
|
||||
<td>
|
||||
{% for tag in book.tag.all %}
|
||||
{% for tag in book.tags.all %}
|
||||
{{tag}},
|
||||
{% endfor %}
|
||||
</td>
|
||||
|
Loading…
Reference in New Issue
Block a user