Modeling user for distance queries

91 Views Asked by At

We want to be able to query local sellers based on seller's preferred distance to a geolocation set by a customer using PostgreSQL and Django models.

Our seller model is given below:

class Seller(AbstractModel):
    user = models.OneToOneField('users.User')
    distance = models.IntegerField()
    geoposition = GeopositionField()

For example: Seller John can travel 50 miles. If buyer's location(lat, long) is 49 miles a John's geoposition, we get John.

1

There are 1 best solutions below

0
visc On

Alternatively you can write a solutions with just postgreSQL.

Try filtering the query using a distance calculation between the buyer and seller location and compare that to the sellers preferred distance.

It appears you want a arithmetic query correct? I think the above example will help you ask me and the community with more questions.