如何解决我怎样才能根据用户的位置获得最近的产品?
我正在使用 geodjango .. 然后我安装了 Python 3 GeoDjango 依赖项(GEOS、GDAL 和 PROJ.4),当然我有 使用 PostgreSQL 和 PostGIS 设置空间数据库 我想获得离我用户位置最近的产品..这是模型
class Prod(models.Model):
userr = models.ForeignKey(User,on_delete=models.CASCADE,null=True,blank=True)
name_business = models.ForeignKey(Page,blank=True)
description = models.CharField(max_length=5000,default="")
disponibilite = models.BooleanField(default=True)
prix = models.DecimalField(decimal_places=2,max_digits=10,blank=True)
Title = models.CharField(max_length=5000,default="")
quantité = models.CharField(max_length=1000,default="")
date_posted = models.DateTimeField(default=timezone.now)
principal_image = models.FileField(blank=True)
location = models.PointField(null=True,default=Point(0.0,0.0))
def __str__(self):
return str(self.Title)
class User(AbstractUser):
geo_location = models.PointField(null=True,0.0))
class Meta:
db_table = 'auth_user'
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。