Skip to content

Commit 72a0e3e

Browse files
author
Tim Schneider
committed
Catching Import exception on ReadOnlyPasswordHashWidget
1 parent 1676667 commit 72a0e3e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

bootstrap3/renderers.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# -*- coding: utf-8 -*-
22
from __future__ import unicode_literals
33

4-
from django.contrib.auth.forms import ReadOnlyPasswordHashWidget
4+
try:
5+
from django.contrib.auth.forms import ReadOnlyPasswordHashWidget
6+
except RuntimeError:
7+
ReadOnlyPasswordHashWidget = None
8+
59
from django.forms import (
610
TextInput, DateInput, FileInput, CheckboxInput, MultiWidget,
711
ClearableFileInput, Select, RadioSelect, CheckboxSelectMultiple
@@ -280,7 +284,7 @@ def add_class_attrs(self, widget=None):
280284
if widget is None:
281285
widget = self.widget
282286
classes = widget.attrs.get('class', '')
283-
if isinstance(widget, ReadOnlyPasswordHashWidget):
287+
if ReadOnlyPasswordHashWidget is not None and isinstance(widget, ReadOnlyPasswordHashWidget):
284288
# Render this is a static control
285289
classes = add_css_class(classes, 'form-control-static', prepend=True)
286290
elif not isinstance(widget, self.WIDGETS_NO_FORM_CONTROL):

0 commit comments

Comments
 (0)