mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
Add tag based filtering
This commit is contained in:
@@ -6,6 +6,11 @@
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
a.badge, a.badge:hover {
|
||||
text-decoration: none;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.tab-pane {
|
||||
min-height: 300px;
|
||||
}
|
||||
|
@@ -85,8 +85,8 @@
|
||||
<p class="card-text"><strong>{{ r }}</strong></p>
|
||||
{% if r.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in r.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% for t in r.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ t.name }}</a>{# new line is required #}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@@ -13,8 +13,8 @@
|
||||
<p class="card-text"><strong>{{ c }}</strong></p>
|
||||
{% if c.tags.all %}
|
||||
<p class="card-text"><small>Tags:</small>
|
||||
{% for t in c.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% for t in c.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ t.name }}</a>{# new line is required #}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@@ -5,8 +5,8 @@
|
||||
<h1 class="fw-light">{{ rolling_stock }}</h1>
|
||||
{% if rolling_stock.tags.all %}
|
||||
<p><small>Tags:</small>
|
||||
{% for t in rolling_stock.tags.all %}<span class="badge bg-primary">
|
||||
{{ t.name }}</span>{# new line is required #}
|
||||
{% for t in rolling_stock.tags.all %}<a href="{% url 'filtered' _filter="tag" search=t.slug %}" class="badge rounded-pill bg-primary">
|
||||
{{ t.name }}</a>{# new line is required #}
|
||||
{% endfor %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
@@ -73,6 +73,8 @@ class GetHomeFiltered(View):
|
||||
)
|
||||
elif _filter == "scale":
|
||||
query = Q(scale__scale__icontains=search)
|
||||
elif _filter == "tag":
|
||||
query = Q(tags__slug__icontains=search)
|
||||
else:
|
||||
raise Http404
|
||||
rolling_stock = (
|
||||
|
Reference in New Issue
Block a user