With Django-1.10 we got the ability to override form fields with our own 
templates, however the form structure is still hard-coded.
Examples are BaseForm.as_table() 
<https://github.com/django/django/blob/129583a0d3cf69b08d058cd751d777588801b7ad/django/forms/forms.py#L269>,
 
BaseForm.as_ul() 
<https://github.com/django/django/blob/129583a0d3cf69b08d058cd751d777588801b7ad/django/forms/forms.py#L279>
 
and BaseForm.as_p() 
<https://github.com/django/django/blob/129583a0d3cf69b08d058cd751d777588801b7ad/django/forms/forms.py#L289>

For instance, the popular Bootstrap framework requires a <div 
class="form-group"> wrapped around each field, so I created a mixin class 
which I add to my Django Forms.
There I added a method named as_div() which renders all my fields in a 
Bootstrap-ish way. This of course is not very intuitive.

My question here is, couldn't we make the arguments normal_row, error_row, 
row_ender and help_text_html, which are passed to method self._html_output, 
more configurable?
Those arguments could maybe be replaced by some special templatetags and 
then consumed by a template responsible to render the form structure in a 
similar way as the as_...() methods mentioned before.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/6eb291eb-91f9-4af0-9cd2-ae3fddc5ae4d%40googlegroups.com.
  • ... Alex Scott
    • ... Confi Yobo
    • ... Carlton Gibson
      • ... Alex Scott
    • ... Jacob Rief
      • ... Carlton Gibson
        • ... Carlton Gibson
        • ... Jacob Rief
    • ... '1337 Shadow Hacker' via Django developers (Contributions to Django itself)

Reply via email to