mirror of
https://github.com/wagtail/wagtail.git
synced 2024-12-01 11:41:20 +01:00
cast an empty string value of AdminChooser to None, as needed by required=True validation
This commit is contained in:
parent
13e1811c54
commit
e3dc4a5936
@ -52,6 +52,14 @@ class AdminChooser(WidgetWithScript, widgets.Input):
|
||||
except model_class.DoesNotExist:
|
||||
return None
|
||||
|
||||
def value_from_datadict(self, data, files, name):
|
||||
# treat the empty string as None
|
||||
result = super(AdminChooser, self).value_from_datadict(data, files, name)
|
||||
if result == '':
|
||||
return None
|
||||
else:
|
||||
return result
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
# allow choose_one_text / choose_another_text to be overridden per-instance
|
||||
if 'choose_one_text' in kwargs:
|
||||
|
Loading…
Reference in New Issue
Block a user