You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Okay, the title is a bit strange, bear with me for a second while I explain.
When I was figuring out how htmx and django played together, I stumbled upon the fact that if you you hx-push-url="true" and that url is a view with a partial template (such as would be used for hx-get), it rendered only that partial. At first I thought, "oh, right. that won't work." So your solution here with checking if a request is request.htmx or not solves that problem nicely.
But then I realized... it could actually be extremely useful for development and testing. When I rendered just that one form I was testing, outside of the context of the rest of the page, it was... really nice. I could hone in on just the component that I was testing, coming from that view. In the case of a modal, the rest of the page is pretty irrelevant when I want to test and develop just that modal in isolation.
So what I started doing was, I had a base.html template that looked like this:
and a base_body.html template that actually contained my 'base layout', my navbar, my structural stuff.
My "pages", like the home page, extend base_body.html and are fully part of the layout.
My "components", like a modal, extend "base.html" so that they get the relevant scripts and css etc, but are rendered in isolation.
So my thought is, can I have both this "render just this component for testing and debugging and stuff" request path, and the dual "partial vs complete" path as demonstrated in your demo? Is that feasible? (More importantly, do I really want it? When I demo it to colleagues, they think it's potentially a really cool feature, but maybe it's silly.) Could there be some sort of DEBUG related flag that allows you to render the partial in a request or in a test?
Thanks for hearing my rambling. Hope some of that made sense.
The text was updated successfully, but these errors were encountered:
Okay, the title is a bit strange, bear with me for a second while I explain.
When I was figuring out how htmx and django played together, I stumbled upon the fact that if you you
hx-push-url="true"
and that url is a view with a partial template (such as would be used for hx-get), it rendered only that partial. At first I thought, "oh, right. that won't work." So your solution here with checking if a request isrequest.htmx
or not solves that problem nicely.But then I realized... it could actually be extremely useful for development and testing. When I rendered just that one form I was testing, outside of the context of the rest of the page, it was... really nice. I could hone in on just the component that I was testing, coming from that view. In the case of a modal, the rest of the page is pretty irrelevant when I want to test and develop just that modal in isolation.
So what I started doing was, I had a
base.html
template that looked like this:and a
base_body.html
template that actually contained my 'base layout', my navbar, my structural stuff.My "pages", like the home page, extend
base_body.html
and are fully part of the layout.My "components", like a modal, extend "base.html" so that they get the relevant scripts and css etc, but are rendered in isolation.
So my thought is, can I have both this "render just this component for testing and debugging and stuff" request path, and the dual "partial vs complete" path as demonstrated in your demo? Is that feasible? (More importantly, do I really want it? When I demo it to colleagues, they think it's potentially a really cool feature, but maybe it's silly.) Could there be some sort of
DEBUG
related flag that allows you to render the partial in a request or in a test?Thanks for hearing my rambling. Hope some of that made sense.
The text was updated successfully, but these errors were encountered: