diff --git a/parks/forms.py b/parks/forms.py index 4e627025..bb7aa705 100644 --- a/parks/forms.py +++ b/parks/forms.py @@ -169,8 +169,8 @@ class ParkForm(forms.ModelForm): # Convert to string to preserve exact decimal places return str(latitude) - except (InvalidOperation, TypeError): - raise forms.ValidationError("Invalid latitude value.") + except (InvalidOperation, TypeError) as e: + raise forms.ValidationError("Invalid latitude value.") from e return latitude def clean_longitude(self): @@ -188,8 +188,8 @@ class ParkForm(forms.ModelForm): # Convert to string to preserve exact decimal places return str(longitude) - except (InvalidOperation, TypeError): - raise forms.ValidationError("Invalid longitude value.") + except (InvalidOperation, TypeError) as e: + raise forms.ValidationError("Invalid longitude value.") from e return longitude def save(self, commit=True):