Closed nanorepublica closed 2 months ago
Thinking about this some more, this probably won't work as an integration since the partial definition and the declaration need to be in the same template file. This is more a ticket for the admin when it gets integrated into core.
Thanks for the report anyway @nanorepublica.
I think this related to #41. The problem is the same: you want to add extra oob
parts onto the end of the response content.
As well as the strategies outlined there, a TemplateResponse
subclass that knew to do the messages.get_messages()
dance would stop this logic leaking into the view (but also not require making it middleware based).
It’s something I’m pondering but I think that’s something more view-layer appropriate (so Neapolitan) rather than template-partials itself (which is about the template tags only really).
Yes you are correct that I took inspiration from #41 and thanks for the tip about TemplateResponse, I will look into that.
I think my general thought when opening this issue was what existing blocks could or would be more appropriate as a partial once template-partials is merged into core. As mentioned this thought is for other parts of core to possibly consider (admin, CBVs, etc) .
@nanorepublica Yep, gotcha.
Like you, I'd love to see us take up HTMX integration here, but I'm not sure exactly how to propose that, or what it might look like. (@jacobian had thoughts when we talked to him on Django Chat.)
Before I detail this issue a couple of disclaimers on this one:
With those two disclaimers aside, I picked up template-partials today to integrate send multiple responses to a custom admin page, one of them being a message.
Essentially I ended up with the following partial template:
Which apart from the one HTMX attribute is pretty much exists right now so I figure this could be an easy win?
It also required this view code which I have seen as a middleware here
I think the main blocker here is the specific HTMX code in the template.