miniature-printer-24569
06/11/2021, 4:48 PMminiature-printer-24569
06/11/2021, 4:48 PMpowerful-controller-56874
06/11/2021, 5:13 PMminiature-printer-24569
06/11/2021, 5:52 PMmysterious-toddler-20573
06/11/2021, 5:52 PMmysterious-toddler-20573
06/11/2021, 5:52 PMminiature-printer-24569
06/11/2021, 5:54 PMminiature-printer-24569
06/11/2021, 5:55 PMpython
def list_detail(request, slug):
list = get_object_or_404(List.objects.all(), slug=slug)
recommendations = ListRecommendation.objects.filter(list=list).select_related(
'created_by',
).prefetch_related(
'agrees',
'disagrees',
'product__software_categories',
'product__software_licenses',
'product__software_platforms',
'product__software_pricings',
'product__images',
).order_by(
'-score'
)
paginator = Paginator(recommendations, 1)
page_number = request.GET.get('page')
paginated_items = paginator.get_page(page_number)
if request.headers.get('HX-Trigger') == 'infinite-scroll-list-recommendations':
template = "_recommendation_list.html"
else:
template = "list-detail.html"
return render(request, template, {
'list': list,
'recommendations': paginated_items,
})miniature-printer-24569
06/11/2021, 5:58 PMpython
{% if recommendations.has_next %}
<div id="infinite-scroll-list-recommendations"
hx-get="{% url 'list-detail' slug=list.slug %}?page={{recommendations.next_page_number }}"
hx-trigger="revealed"
hx-swap="afterend">
{% for recommendation in recommendations %}
{% include '_recommendation.html' %}
{% if forloop.counter|divisibleby:"5" %}
<div class="box">
<div class="w-full bg-gray-200 h-32">
</div>
</div>
{% endif %}
{% endfor %}
</div>
{% else %}
<div>
{% for recommendation in recommendations %}
{% include '_recommendation.html' %}
{% if forloop.counter|divisibleby:"5" %}
<div class="box">
<div class="w-full bg-gray-200 h-32">
</div>
</div>
{% endif %}
{% empty %}
<div class="box">
<p class="text-xl">
No recommendation was found..
</p>
</div>
{% endfor %}
</div>
{% endif %} -> _recommendation_list.htmlminiature-printer-24569
06/11/2021, 6:03 PMmysterious-toddler-20573
06/11/2021, 6:08 PMhx-target is overriding the links?mysterious-toddler-20573
06/11/2021, 6:08 PMminiature-printer-24569
06/11/2021, 6:16 PMminiature-printer-24569
06/11/2021, 6:16 PMmysterious-toddler-20573
06/11/2021, 6:17 PMmysterious-toddler-20573
06/11/2021, 6:17 PMhx-target='body' things might work properly againmysterious-toddler-20573
06/11/2021, 6:18 PMminiature-printer-24569
06/11/2021, 6:18 PMsalmon-xylophone-28580
06/11/2021, 8:06 PMminiature-printer-24569
06/11/2021, 8:16 PMminiature-printer-24569
06/11/2021, 8:29 PMsalmon-xylophone-28580
06/11/2021, 8:31 PMminiature-printer-24569
06/11/2021, 8:43 PMminiature-printer-24569
06/11/2021, 8:44 PMminiature-printer-24569
06/11/2021, 8:51 PMsalmon-xylophone-28580
06/11/2021, 10:10 PMsalmon-xylophone-28580
06/11/2021, 10:12 PM<form hx-post="..." onAfterSwap="..." ? I know this works with hyperscript. But up to now I am happy with htmx and JS.mysterious-toddler-20573
06/11/2021, 11:16 PMbland-rainbow-1285
06/12/2021, 3:41 PMnarrow-room-51024
06/12/2021, 4:58 PM