Skip to content

Problem when automatically rendering form-control-static #159

@massawho

Description

@massawho

Hello, I am new using django-bootstrap3 and it's a nice project. Thank you.
I am entirely replacing the django admin template and found that django-bootstrap3 does not render form-control-static automatically. I found this issue when I replace the form template and saw that the password widget (on user edition page) had a line over the text that says the algorithm, iterations, ,etc.

I managed to workaround the problem, but not sure if it is the best solution, since it will not work for any other widget outside the django-admin that needs to render a div instead of input or something.

Here is my new add_class_attrs function on renderers.py (from line 201)

def add_class_attrs(self):
    classes = self.widget.attrs.get('class', '')
    if isinstance(self.widget, ReadOnlyPasswordHashWidget):
        classes = add_css_class(classes, 'form-control-static', prepend=True)
    else:
        if not isinstance(self.widget, (CheckboxInput,
                                        RadioSelect,
                                        CheckboxSelectMultiple,
                                        FileInput)):
            classes = add_css_class(classes, 'form-control', prepend=True)
            # For these widget types, add the size class here
            classes = add_css_class(classes, self.get_size_class())
    self.widget.attrs['class'] = classes

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions