File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
widget_tweaks/templatetags Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -215,11 +215,20 @@ def render(self, context):
215
215
bounded_field = append_attr (
216
216
bounded_field , f"class:{ context ['WIDGET_REQUIRED_CLASS' ]} "
217
217
)
218
+ attr_dict = {}
218
219
for k , v in self .set_attrs :
220
+ if k == "attr_dict" :
221
+ resolved_dict = v .resolve (context )
222
+ if not isinstance (resolved_dict , dict ):
223
+ raise ValueError (f"{ k } must be of type dict." )
224
+ attr_dict .update (resolved_dict )
225
+ else :
226
+ attr_dict [k ] = v .resolve (context )
227
+ for k , v in attr_dict .items ():
219
228
if k == "type" :
220
- bounded_field .field .widget .input_type = v . resolve ( context )
229
+ bounded_field .field .widget .input_type = v
221
230
else :
222
- bounded_field = set_attr (bounded_field , f"{ k } :{ v . resolve ( context ) } " )
231
+ bounded_field = set_attr (bounded_field , f"{ k } :{ v } " )
223
232
for k , v in self .append_attrs :
224
233
bounded_field = append_attr (bounded_field , f"{ k } :{ v .resolve (context )} " )
225
234
return str (bounded_field )
You can’t perform that action at this time.
0 commit comments