Tweaks for bootstrap5.

- Legacy-Id: 19584
This commit is contained in:
Lars Eggert 2021-11-09 14:02:11 +00:00
parent 8efa37e088
commit 3716d4e95f
2 changed files with 7 additions and 17 deletions

View file

@ -484,32 +484,22 @@ try:
except ImportError:
pass
# Settings for django-bootstrap3
# See http://django-bootstrap3.readthedocs.org/en/latest/settings.html
BOOTSTRAP3 = {
# Settings for django-bootstrap5
# See https://django-bootstrap5.readthedocs.io/en/latest/settings.html
BOOTSTRAP5 = {
# Label class to use in horizontal forms
'horizontal_label_class': 'col-md-2',
# Field class to use in horiozntal forms
'horizontal_field_class': 'col-md-10',
# Set HTML required attribute on required fields
'set_required': True,
# Set placeholder attributes to label if no placeholder is provided
'set_placeholder': False,
# Class to indicate required
'form_required_class': 'bootstrap3-required',
# Class to indicate error
'form_error_class': 'bootstrap3-error',
'field_renderers': {
'default': 'ietf.utils.bootstrap.SeparateErrorsFromHelpTextFieldRenderer',
'inline': 'bootstrap3.renderers.InlineFieldRenderer',
'inline': 'bootstrap5.renderers.InlineFieldRenderer',
},
}
# CORS settings

View file

@ -2,12 +2,12 @@
# -*- coding: utf-8 -*-
import bootstrap3.renderers
import django_bootstrap5.renderers
class SeparateErrorsFromHelpTextFieldRenderer(bootstrap3.renderers.FieldRenderer):
class SeparateErrorsFromHelpTextFieldRenderer(django_bootstrap5.renderers.FieldRenderer):
def append_to_field(self, html):
if self.field_help:
html += '<div class="help-block">{}</div>'.format(self.field_help)
for e in self.field_errors:
html += '<div class="alert alert-danger">{}</div>'.format(e)
return html
return html