Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Can you elaborate on the render fragment on GET/POST part? That sounds interesting!


If you use django-htmx, it's pretty simple to get the "this HTTP request came from HTMX" flag and branch accordingly in your view. The docs give a simple example of the logic here:

https://django-htmx.readthedocs.io/en/latest/middleware.html...

The examples give a fleshed-out version: https://github.com/adamchainz/django-htmx/blob/main/example/...

Though that's very slightly different than how I described it above, but it's basically the same idea; in this case you commonize the `main` block between the two contexts.


See the following video tutorial starting at 9:18 for an example of rendering a template fragment in a Django view that gets returned to HTMX

https://youtu.be/H_m1g8XOtHY




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: