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

    victorious-room-74725

    11/17/2021, 3:42 PM
    One view doing too much is 🤮
  • h

    hundreds-camera-24900

    11/18/2021, 1:29 AM
    So the way I do messages is with a middleware: https://github.com/gone/animelister/blob/master/animelister/util/middleware.py
  • h

    hundreds-camera-24900

    11/18/2021, 1:29 AM
    and then I generate the slot for it in the base template https://github.com/gone/animelister/blob/master/animelister/templates/base.html#L31
  • h

    hundreds-camera-24900

    11/18/2021, 1:29 AM
    and then the messages themselves are a partial
  • h

    hundreds-camera-24900

    11/18/2021, 1:29 AM
    https://github.com/gone/animelister/blob/master/animelister/templates/messages.html
  • h

    hundreds-camera-24900

    11/18/2021, 1:30 AM
    because the messages are tagged with oob, they're inserted directly into the messages div
  • h

    hundreds-camera-24900

    11/18/2021, 1:30 AM
    regardless of what other kind of content is coming through
  • h

    hundreds-camera-24900

    11/18/2021, 1:30 AM
    I just jam a bunch of them on the end of the html fragment
  • h

    hundreds-camera-24900

    11/18/2021, 1:31 AM
    so as you were saying w/ different tabs
  • h

    hundreds-camera-24900

    11/18/2021, 1:31 AM
    because a request that generates a message will get the message jammed onto the response
  • h

    hundreds-camera-24900

    11/18/2021, 1:32 AM
    unless you have some crazy race condition between tabs where one request hits the middleware before the request that generated the message has a chance to
  • h

    hundreds-camera-24900

    11/18/2021, 1:32 AM
    @User ^
  • l

    limited-diamond-93357

    11/18/2021, 1:38 AM
    Thanks @User , that's so helpful!
  • l

    limited-diamond-93357

    11/18/2021, 1:38 AM
    Do you have that written up somewhere?
  • h

    hundreds-camera-24900

    11/18/2021, 1:39 AM
    no
  • h

    hundreds-camera-24900

    11/18/2021, 1:39 AM
    I am still in the "playing around with htmx" phase
  • h

    hundreds-camera-24900

    11/18/2021, 1:39 AM
    the documentation phase comes next
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    the plan is to replace my project template with an htmx based one and then I can force my employees to document my work
  • l

    limited-diamond-93357

    11/18/2021, 1:40 AM
    Sounds like something that could go into django-htmx
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    I thought about that
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    I might make a pr
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    I wanted to sit with it a little more and think about it
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    and I think there's some configuration switches it would need like the message template name
  • h

    hundreds-camera-24900

    11/18/2021, 1:40 AM
    and it also forces a specific message structure
  • h

    hundreds-camera-24900

    11/18/2021, 1:41 AM
    so I was thinking it might make sense to wrap it up into a template tag
  • l

    limited-diamond-93357

    11/18/2021, 1:41 AM
    @high-toothbrush-44006 might have their own idea of how to do it
  • h

    hundreds-camera-24900

    11/18/2021, 1:41 AM
    oh snap I didn't realize he was here
  • l

    limited-diamond-93357

    11/18/2021, 1:42 AM
    Er, I just typed that.
  • l

    limited-diamond-93357

    11/18/2021, 1:42 AM
    Looks like a legit user though
  • l

    limited-diamond-93357

    11/18/2021, 1:43 AM
    github issue perhaps?
1...192021...100Latest