I'm trying to execute a query with the range test in my class (MapArea), but I don't seem to have a grasp on the visibility of objects in Models as I get NameError: name 'MapArea' is not defined
.
My class is as follows:
class MapArea(models.Model):
lat = models.DecimalField(max_digits=15,decimal_places=6)
lon = models.DecimalField(max_digits=15,decimal_places=6)
nearby_streets = MapArea.objects.filter(lat__range=[self.lat - 2, self.lat + 2], lon__range=[self.lon - 2, self.lon + 2])
# Meta
class Meta:
abstract = True
Setting nearby_streets
to MapArea.objects.filter(lat__range=[self.lat - 2, self.lat + 2], lon__range=[self.lon - 2, self.lon + 2])
is what causes the NameError: name 'MapArea' is not defined
.
It seems like MapArea should be defined according to other answers, but I don't seem to be accessing it correctly. How can I access MapArea.objects.filter()
in order to use the range test feature?
Thank you in advance.