Exciting to see people start to pick up template-partials with Django 6.0.
“Wait until you hit upon using them for form field templates”, I quietly whisper 🥳
Exciting to see people start to pick up template-partials with Django 6.0.
“Wait until you hit upon using them for form field templates”, I quietly whisper 🥳
@nanorepublica OK, so...
https://github.com/django/django/compare/main...carltongibson:django:tweaks/simplify-form-templates
... is the start.
Don't know if there'd be appetite for that in #django? (cc @davidsmith )
@adamchainz @nanorepublica @davidsmith Yeah, it's a lot simpler.
But it's the super powers it unlocks that are most fun. 🤩
(Yes, @nanorepublica, busy writing ✍️)
@carlton @adamchainz @nanorepublica
Nice. 👍 (assuming we are happy to adjust the output)
If I had a magic wand I'd change the api so that you can avoid unpacking (field, errors) where `errors` is unused.
@carlton I overrode a form renderer at some point in the past, and it was ugly.
I also needed specific HTML classes based on input type for styling, which, luckily, has been superseded by CSS's `:has()` selector.
Such a long way from this clean template solution, and I love it.
@mahryekuh it’s got a lot nicer in recent years. Partials is the little cherry on top, allowing really neat per field overrides 🍒
(Yes @nanorepublica busy writing ✍️)
@carlton hm.. I see the docs mention; "Template partials can also be included using the include template tag with the same # directive:"
Though I still get "Partial 'journal-metadata' is not defined in the current template."
That's with using;
{% include "example.html#journal-metadata" %}
I have to dig further into that.
But do partials have to be included one by one? Can you import all partials in bulk?
Something like:
{% include "example.html %}
?