HI Alex, 

For label_suffix, I'd say a base form class for your project is exactly the 
way to go. 
You can set CSS classes at the field level[0]
... — I suspect the API is there, but maybe reviewing the guide[1] for 
where it's lacking might be good. 

There are also third-party options, such as Crispy Forms, which can give 
more options. 

[0]: 
https://docs.djangoproject.com/en/2.2/ref/forms/api#django.forms.BoundField.css_classes
[1]: https://docs.djangoproject.com/en/2.2/ref/forms/index
[2]: https://django-crispy-forms.readthedocs.io/en/latest/layouts.html


Hi Jacob — Possibly. Sounds like a moderate change... — what would it look 
like? — proof of concept. (As ever... :) 

Have a good weekend all. 

Kind Regards. 
Carlton 

On Thursday, 10 October 2019 22:18:03 UTC+2, Jacob Rief wrote:
>
> 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/d4412f19-1a36-4097-870b-ee71be9cddc1%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