Fixes #18944: Clearing widget type field no longer causes 500 error (#18946)

* Fixes #18944: Clearing widget type field no longer causes 500 error

* Address PR feedback, cleanup implementation
This commit is contained in:
Jason Novinger 2025-03-20 08:12:05 -05:00 committed by GitHub
parent d7b9b09d56
commit f07e2dd4e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1098,8 +1098,8 @@ class DashboardWidgetAddView(LoginRequiredMixin, View):
if not request.htmx: if not request.htmx:
return redirect('home') return redirect('home')
initial = request.GET or { initial = {
'widget_class': 'extras.NoteWidget', 'widget_class': request.GET.get('widget_class') or 'extras.NoteWidget',
} }
widget_form = DashboardWidgetAddForm(initial=initial) widget_form = DashboardWidgetAddForm(initial=initial)
widget_name = get_field_value(widget_form, 'widget_class') widget_name = get_field_value(widget_form, 'widget_class')