#35192: Support injecting custom context into widget templates -------------------------------------+------------------------------------- Reporter: Oxan van Leeuwen | Owner: nobody Type: | Status: closed Cleanup/optimization | Component: Forms | Version: 5.0 Severity: Normal | Resolution: needsinfo Keywords: | Triage Stage: | Unreviewed Has patch: 0 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 0 Easy pickings: 0 | UI/UX: 0 -------------------------------------+------------------------------------- Changes (by David Smith):
* status: new => closed * resolution: => needsinfo Comment: >it's currently almost impossible to add an invalid CSS class to widgets that have errors. I agree that it is currently tricky to add invalid CSS to widgets (`<inputs>`) and would like to see this eased with Django itself. That was one of my conclusions when I attempted to write a tailwind styled form using just Django itself. See [https://smithdc.uk/blog/2023/bootstrap_form_in_vanilla_django/ blog post]. I think there's a few different design options here, in addition to your suggestion above I see a couple of additional options. - A template filter/tag. This is the approach used by both django-widget- tweaks and django-crispy-forms. - Easing use of a custom `BoundField`. Currently you need to override each field's `get_bound_field()` to achieve this. Maybe this could also be set on the form renderer? This would also allow folk to make other customisations such as #35191 without adding a long list of options to the renderer. It's probably worth starting a discussion on the django forum to gain wider views from the community. I'm happy to help with this discussion. As I think we need a wider discussion on the design I'll mark as 'needsinfo' for now. -- Ticket URL: <https://code.djangoproject.com/ticket/35192#comment:2> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/0107018dabe81c0f-26a6238e-45b9-451e-8d0a-24a626cfcfd6-000000%40eu-central-1.amazonses.com.