[FIX] GEOFENCING: Geofence setup create update issue

This commit is contained in:
Horilla
2025-08-20 16:53:35 +05:30
parent abd7db227e
commit 45ebaae727
3 changed files with 22 additions and 25 deletions

View File

@@ -28,14 +28,15 @@ class GeoFencing(models.Model):
geolocator = Nominatim(
user_agent="geo_checker_unique"
) # Unique user-agent is important
try:
location = geolocator.reverse(
(self.latitude, self.longitude), exactly_one=True
)
if not location:
raise ValidationError("Invalid location coordinates.")
except Exception as e:
raise ValidationError(f"Geolocation error: {e}")
if self.start:
try:
location = geolocator.reverse(
(self.latitude, self.longitude), exactly_one=True
)
if not location:
raise ValidationError("Invalid location coordinates.")
except Exception as e:
raise ValidationError(f"Geolocation error: {e}")
return super().clean()