Changes between Initial Version and Version 1 of Ticket #35191, comment 5


Ignore:
Timestamp:
Feb 14, 2024, 6:48:07 AM (3 months ago)
Author:
Oxan van Leeuwen

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #35191, comment 5

    initial v1  
    33What would also work is to extract the logic that generates the id and contents from `label_tag()` out into separate methods (or properties) of `BoundField`, which can then be used directly in the field template.
    44
    5 The wider context here (and also behind #35192) is that I'm trying to implement something that renders forms in a way that's usable with existing frontend frameworks (such as Bootstrap or Tailwind). Current attempts at this (such as [https://github.com/django-crispy-forms/django-crispy-forms django-crispy-forms] or [https://github.com/zostera/django-bootstrap5 django-bootstrap5]) all render using a custom template tag, whose implementation pokes around in the internals of the forms component. In my experience those always have hardcoded special casing and can't support the full feature set and extensibility of the forms component. It'd be great if something like that could be implemented in plain Django, working along with instead of around the forms component. Form renderers seem like the logical extension point for such an implementation, and they're nearly there, but at the moment they are a bit too inflexible to cleanly allow all necessary customization.
     5The wider context here (and also behind #35192) is that I'm trying to implement something that renders forms in a way that's usable with existing frontend frameworks (such as Bootstrap or Tailwind). Current attempts at this (such as [https://github.com/django-crispy-forms/django-crispy-forms django-crispy-forms] or [https://github.com/zostera/django-bootstrap5 django-bootstrap5]) all render using a custom template tag, whose implementation pokes around in the internals of the forms component. In my experience those always have hardcoded special casing and can't support the full feature set and extensibility of the forms component. It'd be great if something like that could be implemented in plain Django, working along with instead of around the forms component. Form renderers seem like the logical extension point for such an implementation, and they're nearly there, but at the moment they are a bit too inflexible to cleanly allow all necessary customization.
     6However, I do think both of these issues have a wider impact than just this project of mine, and resolving them will also be useful for others that want to customize form rendering in different ways.
Back to Top