About Functions Returning Multiple Values
When you need to return multiple values by a function, use named tuple for the most flexibility.
from collections import namedtuple
Geoposition = namedtuple("Geoposition", ["latitude", "longitude"])
def get_location_geoposition(location_id):
location = Location.objects.get(pk=location_id)
return Geoposition(location.latitude, location.longitude)
latitude, longitude = get_location_geoposition(1)
print(latitude)
print(longitude)
geoposition = get_location_geoposition(2)
print(geoposition.latitude)
print(geoposition.longitude)
Also by me
Django Paddle Subscriptions app
For Django-based SaaS projects.
Django App for You
Django GDPR Cookie Consent app
For Django websites that use cookies.
Django App for You