Skip to content

Commit 0e07b65

Browse files
committed
Fix error
1 parent 882f141 commit 0e07b65

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

opendrift_leeway_webgui/leeway/forms.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,6 @@ class LeewaySimulationForm(ModelForm):
5050
decimal value in the ``clean_latitude`` / ``clean_longitude`` methods.
5151
"""
5252

53-
# Override model FloatFields as not-required so that returning None from
54-
# clean_latitude / clean_longitude (when a sub-field already reported an
55-
# error) does not produce a duplicate "This field is required." message.
56-
latitude = FloatField(required=False)
57-
longitude = FloatField(required=False)
58-
5953
#: Direction choices for latitude
6054
LAT_DIR_CHOICES = [("N", "N"), ("S", "S")]
6155
#: Direction choices for longitude
@@ -119,6 +113,13 @@ class LeewaySimulationForm(ModelForm):
119113
widget=Select(attrs={"class": "coord-dir coord-lon"}),
120114
)
121115

116+
# Declared after all sub-fields so that clean_latitude / clean_longitude
117+
# run after the sub-fields are already present in cleaned_data.
118+
# required=False avoids a duplicate "This field is required." message when
119+
# a sub-field already reported an error and clean_* returns None.
120+
latitude = FloatField(required=False)
121+
longitude = FloatField(required=False)
122+
122123
class Meta:
123124
"""
124125
Configure form fields and help text.

0 commit comments

Comments
 (0)