Skip to content

Instantly share code, notes, and snippets.

@JorgeMichelena
Created Sep 19, 2022
Embed
What would you like to do?
from django.contrib.gis.db.models.functions import Distance
matching_targets = (
Target.objects
.annotate(distance=Distance("location", my_target.location))
.filter(distance__lte=(F("radius_in_mts") + my_target.radius_in_mts))
.filter(topic=my_target.topic)
.exclude(user_id=my_target.user_id)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment