Here is the full template…
{% extends 'main.html' %}
{% block content %}
{% load static %}
<h3 class="text-warning bg-secondary px-5 pt-2 pb-2">Album Gallery</h3>
<div class="container-mt-4 d-flex align-items-center justify-content-center">
{% if show_list %}
<a href="{% url 'albums' %}" title="Return to Album List">
<button type="button" class="btn btn-primary" style="width: 250px;">Return to Album List</button>
</a>
{% else %}
<a href="{% url 'albums_grid' %}" title="Return to Album Grid">
<button type="button" class="btn btn-primary" style="width: 250px;">Return to Album Grid</button>
</a>
{% endif %}
{# <a href="{% url 'album_sections' album_object.id source %}">#}
{# <button type="button" class="btn btn-primary" style="width: 250px;">Return to Chapter List</button>#}
{# </a>#}
</div>
<div>
{{ htmx_status }}
</div>
<div hx_get="/albums/album_partial_gallery/" hx_trigger="load">
Loading gallery...
</div>
{% endblock content %}
Here is the view that loads this template…
def album_gallery_test(request, album_section_id):
source = request.session['album_source']
show_list = True
if source == 'grid':
show_list = False
if request.headers.get('HX-Request'):
htmx=True
else:
htmx=False
context = {
"source": source,
"show_list": show_list,
"htmx_status": htmx,
}
return render(request, 'Albums/albums_lazy_images.html', context)
Here is the code that should be called from the “load” event but I confirmed from the debugger that it never gets here…
def album_partial_gallery(request):
time.sleep(2)
context = {}
return render(request, 'Albums/Partials/album_images.html',context)
Please let me know if you need to see anything else.
Thanks.