https://htmx.org logo
Join Discord
Powered by
# πŸ”₯-django-htmx
  • r

    refined-waiter-90422

    07/14/2022, 2:52 PM
    So you have quite a few options without touching javascript, a good list of them here:
  • r

    refined-waiter-90422

    07/14/2022, 2:54 PM
    Basically 1cg is suggesting this method:
  • h

    handsome-shampoo-48908

    07/14/2022, 3:19 PM
    But i'm already use the hx-target for update my list of tasks
  • r

    refined-waiter-90422

    07/14/2022, 3:30 PM
    So expand the container, or: Or Would suggest reading the page so you are aware of what options are available to you before using javascript.
  • r

    refined-waiter-90422

    07/14/2022, 3:32 PM
    Quite a few ways to do it. Gotta choose the best pattern for your workflow.
  • h

    handsome-shampoo-48908

    07/14/2022, 3:38 PM
    Ok i will continue to search, I don't really understand how to use these options and my tests are not conclusive.
  • m

    melodic-advantage-28381

    07/15/2022, 9:13 PM
    See you guys there πŸ˜‰ https://twitter.com/DjangoConEurope/status/1547235261347758080
  • b

    bumpy-zoo-26881

    07/17/2022, 9:37 AM
    Hey, any idea how to reinitialize flatpickr when inserting a form via htmx ajax request?
  • a

    acceptable-student-40393

    07/17/2022, 10:31 AM
    Hi all, I am currently working on an app which uses Django, Alpine.js, and HTMX. I have a table, which upon a search form submission gets swapped out via HTMX. This works well. However, there is a slight delay before everything is loaded. In this time period, I want to show a loading screen. What would be the best way to show a loading screen until all elements have been swapped properly. At the moment I have this set up (simplified to post here): https://pastebin.com/v0e854L5
  • a

    acceptable-student-40393

    07/17/2022, 10:33 AM
    I tried adding the following alpine.js x-on event (just trying to log to console atm) on the html piece that gets swapped by HTMX:
    Copy code
    <div id="search_results" @htmx:before-swap="console.log('Hello World!')">
    ..stuff here ...
    </div>
    But that doesn't seem to fire off the console log. Would appreciate any pointers in the right direction.
  • r

    ripe-action-67367

    07/17/2022, 11:35 AM
    Check out https://htmx.org/extensions/loading-states/
  • r

    ripe-action-67367

    07/17/2022, 11:36 AM
    Also, the event is htmx:beforeSwap, not before-swap
  • c

    calm-queen-64495

    07/18/2022, 2:45 AM
    Trying to use Infinite load with djangos ListView and paginate_by, though I can't seem to get it to work properly, has anyone accomplished this?
  • b

    blue-ghost-19146

    07/18/2022, 6:51 AM
    Where do you think you’re having trouble? Using the
    Paginator
    class, accessing the data in the template, choosing the correct
    hx-
    attributes?
  • b

    blue-ghost-19146

    07/18/2022, 6:51 AM
    I’ve implemented pagination with htmx and Django, but not infinite load, happy to try and help 😊
  • c

    calm-queen-64495

    07/18/2022, 6:59 AM
    So I followed BugBites tutorials here

    https://www.youtube.com/watch?v=RacU_1NgVIg&t=419sβ–Ύ

    I have 2 views, a ListView using the classed based method, and a search view on the same page to filter by name.
    Copy code
    class ClientList(ListView):
        model = User
        template_name = 'clients.html'
        paginate_by = 4
        context_object_name = 'people'
        
        def get_template_names(self):
            if self.request.htmx:
                return 'partials/client_card.html'
            return 'clients.html'
    
        def get_queryset(self):
            return User.objects.all().exclude(admin = True)
    def client_search(request):
        if request.method == "POST":
            search = request.POST['search']
            people = User.objects.filter(Q(firstname__icontains=search) | Q(lastname__icontains=search)).exclude(admin = True)
            context = {
                'people': people
            }
        return render(request, 'partials/client_card.html', context)
  • c

    calm-queen-64495

    07/18/2022, 7:00 AM
    Looks like a recursive error as my search view is a htmx request
  • c

    calm-queen-64495

    07/18/2022, 7:00 AM
    so triggers that
  • c

    calm-queen-64495

    07/18/2022, 7:01 AM
    Copy code
    {% for person in people %}
    {% if forloop.last %}
    <div hx-get="{% url 'clients' %}?page={{ page_obj.number|add:1 }}" hx-trigger="revealed" hx-swap="afterend" hx-target="this" class="col col-md-6 col-12 col-xl-4" style="padding: 0;">
    
    {% else %}
    <div class="col col-md-6 col-12 col-xl-4" style="padding: 0;">
    {% endif %}
        <div class="card" style="margin: 5px;">
            <div class="card-body" style="margin: 0;">
                <div class="row">
                    <div class="col text-center align-self-center"><img class="rounded-circle people-face bg-light" src="{{person.profile_image.url}}"><i class="fa fa-female people-icon" data-bs-toggle="tooltip" data-bss-tooltip="" title="Female"></i></div>
                </div>
                <h4 class="text-primary card-title">
                    <a href="{% url 'admin-view-client' person.pk %}">{{person.get_full_name}}</a>
                </h4>
                <h6 class="text-muted card-subtitle mb-2"><em>{{person.suburb}}</em></h6>
                <h6 class="text-muted card-subtitle mb-2" style="font-size: 13px;">NDIS: 4306734567, MANAGER: Woov Pay</h6>
                <p class="card-text">Next Booking: <strong>16/6/2022</strong></p>
                <div class="row" style="padding: 0;">
                    <div class="col"><i class="fa fa-phone-square fs-1 text-primary" style="margin: 5px;"></i><i class="fa fa-envelope-square fs-1 text-primary" style="margin: 5px;"></i></div>
                </div>
            </div>
        </div>
    </div>
    
    {% endfor %}
  • c

    calm-queen-64495

    07/18/2022, 7:01 AM
    Template code
  • c

    calm-queen-64495

    07/18/2022, 7:01 AM
    to which uses the hx-trigger="revealed"
  • h

    hundreds-camera-24900

    07/18/2022, 6:01 PM
    here's how I did it in the past
  • h

    hundreds-camera-24900

    07/18/2022, 6:01 PM
    https://github.com/gone/animelister/blob/master/animelister/templates/home/partials/anime_table.html#L2
  • b

    blue-ghost-19146

    07/18/2022, 7:32 PM
    @calm-queen-64495 do you have any more info about how it isn't working? Returning the wrong page / getting server or htmx errors? Only thing I see from a quick glance is that you could possibly use
    hx-get="{% url 'clients' %}?page={{ page_obj.next_page_number }}"
    instead of
    .number|add:1
    . Gone's example looks good - does it help solve your issue at all?
  • i

    icy-scooter-3369

    07/18/2022, 9:25 PM
    Hi, everyone. I'm new here. I'm learning HTMX
  • i

    icy-scooter-3369

    07/18/2022, 9:25 PM
    Now I'm trying HTMX without CDN. Just Downloaded htmx.min.js and used tag, like documentation says, but can get it to work. With CDN, works fine. Don't know yet whatil is wrong
  • i

    icy-scooter-3369

    07/18/2022, 9:27 PM
    Browser GET code 200 when trying to get the js file, so the src in script tag is right.
  • b

    blue-ghost-19146

    07/18/2022, 9:54 PM
    Hm strange. Is it possible to see how you’re calling it, and what the browser’s network tab is showing?
  • b

    blue-ghost-19146

    07/18/2022, 9:54 PM
    And welcome, btw! 😁
  • i

    icy-scooter-3369

    07/18/2022, 10:50 PM
    Hi! Tanks for your time.
1...656667...100Latest