Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an utility property for the non boosted htmx request case #222

Closed
DevOpsCraftsman opened this issue May 7, 2022 · 2 comments
Closed

Comments

@DevOpsCraftsman
Copy link

DevOpsCraftsman commented May 7, 2022

Description

Hi Adam!
Thanks for this useful package.

Here is a pattern that could be useful in several places (views or templates) :

if self.request.htmx and not self.request.htmx.boosted:

It helps pointing out when we really want to use a fragment template.
A real example here.

It could be interesting to add it a wrapper property, don’t know how to name it though (unboosted???)...

If I would like to add it manually, it would mean patching HtmxDetail, or make a custom middleware with a subclass of HtmxDetail

@adamchainz
Copy link
Owner

Hey!

I am not sure what you're doing is particularly common... normally with htmx I write views that are for htmx only. I haven't considered combining both boosting and fragment fetching for the same view.

Also, it's not a particularly complicated expression that you'd like to simplify, and in your example you only use it in one place?

I would like to see more people say they have this use case before considering adding it. For now you could add a custom subclass and middleware in your project as I wrote in #223.

Thanks,

Adam

@DevOpsCraftsman
Copy link
Author

DevOpsCraftsman commented May 7, 2022

I have a project with hundreds and hundreds of CBVs, and I was’nt using htmx at the beginning.
Rewrite everything from scratch would be a pain, so I was searching a solution to start using htmx gradually.
A discussion in the django channel of the htmx discord with people help me think about it.

But yes, you are right, keeping django_htmx the more minimalist possible and non opinionated is probably better.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants