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

    bitter-dog-98292

    11/22/2021, 4:28 PM
    And no need for async Django
  • b

    bitter-dog-98292

    11/22/2021, 4:28 PM
    If you want to poll from the frontend, use htmx
  • b

    bitter-dog-98292

    11/22/2021, 4:29 PM
    If you want to poll from Django, use a task manager like celery, Django rq, etc.
  • h

    hundreds-camera-24900

    11/22/2021, 9:38 PM
    yeah I can contribute something, been pretty slammed in the lead up to the holidays
  • c

    careful-room-54859

    11/22/2021, 11:41 PM
    Hi everyone, I have a question that I am hoping you can help me with. I have a list view that paginates the results back based on a search. As you can see below, the URL is updated correctly with the search and pagination params but I would also like the INPUT element to have the search params still in it....
  • c

    careful-room-54859

    11/22/2021, 11:42 PM
    I would like for the INPUT to also have the value
    ag
    after the
    hx-get
    returns but this is OOB and it doesn't seem to work and adds a secondary INPUT at the bottom....
  • c

    careful-room-54859

    11/23/2021, 12:08 AM
    I ended up refactoring my template to include the INPUT and then used the following:
    Copy code
    html
                <input id="search" name="search" 
                  class="block w-full pl-10 pr-3 py-2 textinput border border-gray-300 rounded-md leading-5 bg-white focus:outline-none sm:text-sm"
                  placeholder="Search"
                  type="search"
                  value="{% for key,value in request.GET.items %}{% ifequal key 'search' %}{{ value }}{% endifequal %}{% endfor %}"
                  autofocus
                  hx-get="{% url 'entities:list' %}"
                  hx-trigger="keyup changed delay:500ms" 
                  hx-target="#viewport"
                  hx-push-url="true">
  • c

    careful-room-54859

    11/23/2021, 12:08 AM
    value
    is what give is back to me.....If there is an easier way to do this, I am happy to learn but this does work......
  • b

    bulky-jelly-23602

    11/23/2021, 10:46 PM
    Does
    django-htmx
    add any functionality to the Django side of things? Like if I was writing an application in a different framework and just using the HTMX library on the client side would I be missing out on anything?
  • h

    hundreds-camera-24900

    11/23/2021, 11:55 PM
    not really
  • h

    hundreds-camera-24900

    11/23/2021, 11:56 PM
    it's mostly a set of django side tools to set/detect headers and issue response codes specific to htmx
  • h

    hundreds-camera-24900

    11/23/2021, 11:56 PM
    you could do all of that in a different framework
  • b

    bland-coat-6833

    11/24/2021, 6:20 AM
    I have pinched the HtmxDetails class and used it with FastAPI without any trouble, for example.
  • l

    limited-diamond-93357

    11/24/2021, 7:31 AM
    It's also the
    {% django_htmx_script %}
    tag, how could we forget! πŸ˜„
  • b

    bulky-jelly-23602

    11/24/2021, 5:00 PM
    Thanks everyone for the details!
  • p

    prehistoric-cat-63987

    11/24/2021, 9:35 PM
    Hello everyone. Django throws "403 (CSRF missing or incorrect) " anytime I send a hx-delete or hx-put request despite having my csrf_token bounded to my form or in the header. I don't know what seems to be wrong I had to change all my methods back to post and get alone. Btw, I'm using Django generic base view "from django.views import View"
  • p

    prehistoric-cat-63987

    11/24/2021, 9:36 PM
    I would have love to post the codes but im on mobile
  • p

    prehistoric-cat-63987

    11/24/2021, 9:36 PM
    I just want to ask if it's normal or not
  • b

    bland-coat-6833

    11/25/2021, 7:51 AM
    Looks like you’re not the first: https://stackoverflow.com/questions/13089613/ajax-csrf-and-delete But seems odd that it’s not working if it’s in the header. Does devtools show the X-CSRFToken being sent?
  • p

    prehistoric-cat-63987

    11/25/2021, 7:53 AM
    Yeah, the csrf token is sent. I just can't figure what is wrong.
  • p

    prehistoric-cat-63987

    11/25/2021, 7:57 AM
    HTMX can give use something for the suggested solution in the SO link you posted, I don't know how to implement the X-CsrfToken with htmx
  • e

    elegant-london-97728

    11/25/2021, 2:02 PM
    I'm currently using
    django-autocomplete-light
    to provide a
    Select2
    -based
    ModelSelect2
    widget in many of my django forms. This uses
    jQuery
    , which I'd like to eventually get rid of. Does anybody happen to know if there exists a good htmx-based replacement? @User does
    tom-select
    work out well for you and would you recommend going down that road?
  • p

    prehistoric-keyboard-16601

    11/26/2021, 10:12 AM
    To attach the CSRF token with HTMX, this video shows for DELETE requests

    https://youtu.be/qk1gVbnaOAc?t=433β–Ύ

  • p

    prehistoric-cat-63987

    11/26/2021, 10:58 AM
    Thanks allot man.
  • s

    salmon-xylophone-28580

    11/28/2021, 2:22 PM
    For me tom-select worked fine. But iirc you need some JS do that it works. There is a stackoverflow question about this. I think I have seen a pure htmx solution some days ago.
  • a

    adamant-pencil-3809

    11/29/2021, 8:22 AM
    Hi there! I wrote a blog article at Medium about my (awesome) experience with HTMX and django... Would be happy to get some feedback: https://medium.com/ambient-innovation/interactive-zero-javascript-sites-with-django-dcb9e903c8ad?source=collection_home---4------0----------------------- πŸ™‚
  • m

    mysterious-toddler-20573

    11/29/2021, 2:13 PM
    hi richard, thank you for writing about htmx πŸ™‚ one small thing that I noticed is that you sometimes use the word "tag" when I think you mean "attribute": > We see a button that has a special HTMX-tag containing the URL to post a request to. should maybe read: > We see a button that has a special HTMX attribute containing the URL to post a request to.
  • b

    brave-raincoat-81051

    11/30/2021, 6:06 PM
    this is super cool, I've been using django for a long time and HTMX only for a few weeks now but I hadn't really used it for events that I've defined before. Thank you very much for writing the article
  • f

    fast-baker-86727

    12/03/2021, 6:41 PM
    Hi folks, Django noob here. I know htmx sends a header with its requests so that on the backend, you can determine whether to deliver a partial or a full-page template--does anyone know how, in a class-based view that I'm working with, I grab that header?
  • b

    bland-coat-6833

    12/03/2021, 6:44 PM
    Add this middleware and you’ll get an
    htmx
    property on the request object.
1...212223...100Latest