https://htmx.org logo
Join Discord
Powered by
# 🔥-django-htmx
  • m

    millions-morning-77621

    12/12/2021, 10:04 AM
    This seems so cool
  • m

    millions-morning-77621

    12/12/2021, 10:04 AM
    I have been slacking
  • l

    limited-diamond-93357

    12/12/2021, 12:34 PM
    Welcome! Exciting times!
  • l

    limited-diamond-93357

    12/12/2021, 12:35 PM
    I'm starting my latest Django app this week after a break of several years from professional development. I'm so looking forward to it!
  • m

    millions-morning-77621

    12/12/2021, 12:58 PM
    Nice dude!
  • m

    millions-morning-77621

    12/12/2021, 12:58 PM
    I have made 3 major projects with django, if you ever have any questions, I could give it a try
  • m

    millions-morning-77621

    12/12/2021, 12:58 PM
    But you probably know it better than me
  • l

    limited-diamond-93357

    12/12/2021, 1:09 PM
    Thank you for the offer.
  • m

    millions-morning-77621

    12/12/2021, 1:09 PM
    Also has anyone come across a great video detailing how to effective use django and htmx
  • m

    millions-morning-77621

    12/12/2021, 1:10 PM
    Like the work flow and the stuff you could do
  • m

    millions-morning-77621

    12/12/2021, 1:10 PM
    And security and things
  • m

    millions-morning-77621

    12/12/2021, 1:10 PM
    I would be okay with articles and posts as well
  • m

    millions-morning-77621

    12/12/2021, 1:11 PM
    It will save me a bunch of time :)
  • l

    limited-diamond-93357

    12/12/2021, 1:20 PM
    I think this is quite a nice series. https://www.youtube.com/playlist?list=PL-2EBeDYMIbRByZ8GXhcnQSuv2dog4JxY
  • m

    millions-morning-77621

    12/12/2021, 1:22 PM
    Thanks man
  • m

    millions-morning-77621

    12/12/2021, 1:22 PM
    I will have a look
  • s

    silly-airline-58853

    12/12/2021, 3:43 PM
    Just ran a diff on the before and after sort html, the only difference other than the order seems to be the csrf token
  • f

    fierce-portugal-2651

    12/13/2021, 11:03 AM
    Hello, I am new to HTMX but definitely want use it in my next project alongside with Django. I am only considering regarding support of mobile clients - native Android, IOs apps. What could you recommend for mobile apps data exchange, Django Rest Framework or something else?
  • p

    prehistoric-cat-63987

    12/13/2021, 11:36 AM
    Since it's for mobile app and not just website or probably the app and website would share the same backend, then you'll need to use DRF
  • f

    fierce-portugal-2651

    12/13/2021, 12:04 PM
    Thank you. Yes, web site and mobile apps. Because HTMX is intended not to use REST API for website am I asking such question, maybe there are different approaches for exchanging data between server and mobile apps
  • p

    prehistoric-cat-63987

    12/13/2021, 12:55 PM
    As far as you're using Rest Framework, your JS frontend(Vue, React or Angular) would handle everything for you. Htmx help improve Server side rendered pages not JSON .
  • f

    fast-baker-86727

    12/13/2021, 9:18 PM
    Does anyone know if/how you can send htmx responses manually from the server? What I mean is: I've got a form that, ordinarily, I want to do a full-page load to a new URL, but if there are errors, I'd like to return that as a partial and update the form piece. I assume that there's nothing really to do in the template, but I would handcraft a response in my view with some headers maybe that htmx will read when it receives them?
  • b

    bumpy-portugal-30413

    12/13/2021, 9:20 PM
    Maybe HX-Trigger header is what you are looking for? https://htmx.org/headers/hx-trigger/
  • b

    bumpy-portugal-30413

    12/13/2021, 9:24 PM
    But if you just want to render the errors in the form can't you just return a response that has the form component replacing the current one with {{ errors }} in the context?
  • f

    fast-baker-86727

    12/13/2021, 9:28 PM
    Right, that's what I want to do, but if there are no errors, I just want the thing to do a full page-load as normal. So is there any mojo for manually initiating an htmx response from the server? E.g., I'm thinking something like (this is pseudo-code):
    Copy code
    if no-errors:
        return response(new_full_page)
    else if errors:
        return HtmxResponse(errors)
    Like can I manually add headers to my response to do something like this? Or am I thinking about it completely wrong? 🤔
  • f

    fast-baker-86727

    12/13/2021, 9:34 PM
    Would this perhaps be best handled with something like Hx-Redirect for the "full page" response?
  • b

    bumpy-portugal-30413

    12/13/2021, 9:40 PM
    That pseudocode is how I was thinking of it - you don't need headers to achieve this particular thing.
    Copy code
    if no-errors:
        return response(new_full_page)
    else if errors:
        return render(request, component, {"errors": errors})
    in the component is your html template that has the form which will replace the form on the page using the hx-target and swap
  • b

    bumpy-portugal-30413

    12/13/2021, 9:44 PM
    Then I guess with the full page reload, do you actually need to do a refresh, or you just want to replace all the content?
  • b

    bumpy-portugal-30413

    12/13/2021, 9:48 PM
    The way I added headers for HX-Trigger was
    Copy code
    response = render(request, component, {"errors": errors})
    response[HX-Trigger] = "eventName"
    return response
    Then listen for that event. I used that to update an element when other elements were updated. I haven't used redirect so I assume you set the url as the header? There isn't a doc page for that one.
  • f

    fast-baker-86727

    12/13/2021, 9:53 PM
    Right, it's not a reload, this would return a completely new page. That's why I'm wondering if doing
    response['Hx-Redirect'] = "some/url/here"
    (if that's the syntax--like you said, it doesn't have a doc page) is maybe what I'm looking for
1...242526...100Latest