77import htmlgenerator as hg
88from _strptime import TimeRE
99from django .conf import settings
10- from django .forms import widgets
10+ from django .forms import widgets as djangowidgets
1111from django .urls import reverse
1212from django .utils import formats
1313from django .utils .translation import gettext_lazy as _
@@ -84,7 +84,7 @@ def with_fieldwrapper(self):
8484
8585
8686class HiddenInput (BaseWidget ):
87- django_widget = widgets .HiddenInput
87+ django_widget = djangowidgets .HiddenInput
8888 input_type = "hidden"
8989
9090 def __init__ (
@@ -100,7 +100,7 @@ def __init__(
100100
101101
102102class TextInput (BaseWidget ):
103- django_widget = widgets .TextInput
103+ django_widget = djangowidgets .TextInput
104104 carbon_input_class = "bx--text-input"
105105 carbon_input_error_class = "bx--text-input--invalid"
106106 input_type = "text"
@@ -166,23 +166,23 @@ def __init__(self, *args, **attributes):
166166
167167
168168class UrlInput (TextInput ):
169- django_widget = widgets .URLInput
169+ django_widget = djangowidgets .URLInput
170170 input_type = "url"
171171
172172 def __init__ (self , * args , ** attributes ):
173173 super ().__init__ (* args , icon = "link" , ** attributes )
174174
175175
176176class EmailInput (TextInput ):
177- django_widget = widgets .EmailInput
177+ django_widget = djangowidgets .EmailInput
178178 input_type = "email"
179179
180180 def __init__ (self , * args , ** attributes ):
181181 super ().__init__ (* args , icon = "email" , ** attributes )
182182
183183
184184class NumberInput (BaseWidget ):
185- django_widget = widgets .NumberInput
185+ django_widget = djangowidgets .NumberInput
186186 input_type = "number"
187187
188188 def __init__ (
@@ -225,12 +225,12 @@ def __init__(
225225
226226
227227class TimeInput (TextInput ):
228- django_widget = widgets .TimeInput
228+ django_widget = djangowidgets .TimeInput
229229 input_type = "time"
230230
231231
232232class PasswordInput (TextInput ):
233- django_widget = widgets .PasswordInput
233+ django_widget = djangowidgets .PasswordInput
234234 carbon_input_class = "bx--password-input bx--text-input"
235235 carbon_input_error_class = "bx--text-input--invalid"
236236 input_type = "password"
@@ -276,7 +276,7 @@ def __init__(
276276
277277
278278class Textarea (BaseWidget ):
279- django_widget = widgets .Textarea
279+ django_widget = djangowidgets .Textarea
280280 carbon_input_class = "bx--text-area bx--text-area--v2"
281281 carbon_input_error_class = "bx--text-area--invalid"
282282
@@ -327,7 +327,7 @@ def __init__(
327327
328328
329329class Select (BaseWidget ):
330- django_widget = widgets .Select
330+ django_widget = djangowidgets .Select
331331 carbon_input_class = "bx--select-input"
332332
333333 def __init__ (
@@ -509,11 +509,11 @@ def __init__(
509509
510510
511511class NullBooleanSelect (Select ):
512- django_widget = widgets .NullBooleanSelect
512+ django_widget = djangowidgets .NullBooleanSelect
513513
514514
515515class SelectMultiple (BaseWidget ):
516- django_widget = widgets .SelectMultiple
516+ django_widget = djangowidgets .SelectMultiple
517517
518518 def __init__ (
519519 self ,
@@ -672,7 +672,7 @@ def countselected(context):
672672
673673
674674class Checkbox (BaseWidget ):
675- django_widget = widgets .CheckboxInput
675+ django_widget = djangowidgets .CheckboxInput
676676 carbon_input_class = "bx--checkbox"
677677 input_type = "checkbox"
678678
@@ -727,7 +727,7 @@ def __init__(
727727
728728
729729class CheckboxSelectMultiple (BaseWidget ):
730- django_widget = widgets .CheckboxSelectMultiple
730+ django_widget = djangowidgets .CheckboxSelectMultiple
731731 carbon_input_class = "bx--checkbox"
732732 input_type = "checkbox"
733733
@@ -813,7 +813,7 @@ def __init__(
813813
814814
815815class RadioSelect (BaseWidget ):
816- django_widget = widgets .RadioSelect
816+ django_widget = djangowidgets .RadioSelect
817817 carbon_input_class = "bx--radio-button"
818818 input_type = "radio"
819819
@@ -862,7 +862,7 @@ def __init__(
862862
863863
864864class DatePicker (BaseWidget ):
865- django_widget = widgets .DateInput
865+ django_widget = djangowidgets .DateInput
866866 carbon_input_class = "bx--date-picker__input"
867867 input_type = "text" # prevent browser style date picker but use carbon design
868868
@@ -973,7 +973,7 @@ def format_date_value(context):
973973
974974
975975class FileInput (BaseWidget ):
976- django_widget = widgets .FileInput
976+ django_widget = djangowidgets .FileInput
977977 carbon_input_class = "bx--file-input bx--visually-hidden"
978978 input_type = "file"
979979 clearable = False
@@ -1125,7 +1125,7 @@ def __init__(
11251125
11261126
11271127class ClearableFileInput (FileInput ):
1128- django_widget = widgets .ClearableFileInput
1128+ django_widget = djangowidgets .ClearableFileInput
11291129 clearable = True
11301130
11311131
@@ -1228,7 +1228,7 @@ def AjaxSearch(url, formatter=str):
12281228
12291229
12301230class MultiWidget (BaseWidget ):
1231- django_widget = widgets .MultiWidget
1231+ django_widget = djangowidgets .MultiWidget
12321232
12331233 def __init__ (
12341234 self ,
@@ -1277,10 +1277,10 @@ def subwidget(self, boundfield, djangowidget, djangodata, i):
12771277
12781278
12791279class SplitDateTimeWidget (MultiWidget ):
1280- django_widget = widgets .SplitDateTimeWidget
1280+ django_widget = djangowidgets .SplitDateTimeWidget
12811281
12821282 def subwidget (self , boundfield , djangowidget , djangodata , i ):
1283- if isinstance (djangowidget , widgets .DateInput ):
1283+ if isinstance (djangowidget , djangowidgets .DateInput ):
12841284 return DatePicker (
12851285 label = None ,
12861286 help_text = None ,
@@ -1416,6 +1416,7 @@ def _optgroups_from_choices(optchoices, name, value):
14161416
14171417def django2bread_widgetclass (widgetclass , fieldclass = None ) -> Optional [hg .Lazy ]:
14181418 if django2bread_widgetclass .widget_map is None : # type: ignore
1419+
14191420 django2bread_widgetclass .widget_map : dict = {} # type: ignore
14201421 for cls in get_all_subclasses (BaseWidget ):
14211422 if cls .django_widget not in django2bread_widgetclass .widget_map : # type: ignore
0 commit comments