具有location__dwithin的过滤器不起作用-可能是因为指定的范围不是以度为单位

时间:2018-11-02 20:52:21

标签: python django postgis geodjango

我正在尝试使用location__dwithin,但是它的输出为

<div class="container">
  <div class="row">
    <div class="col l6 offset-l3">
      <div class="card center-align">
        <div class="card-content">
          <span class="card-title">
            Local Weather App
          </span>
          <img id="weather-icon" src="" alt="Loading Icon">
          <div class="weather-info">
            <span id="location"></span> / 
            <span id="temperature"></span>ºC / 
            <span id="weather-text"></span>
          </div>
        </div>
        
        <div class="card-action">
          <form id="search-weather">
            <input type="text" name="location" placeholder="Your location">
            <button type="submit" class="btn">Find Weather</button>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

这是我的模特

Unable to get repr for <class 'django.db.models.query.QuerySet'>

这是我正在使用的代码

class modelEmployee(models.Model):
    user                = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
    title               = models.CharField(max_length=200, unique=False, blank=False, null=True)
    location            = models.PointField(srid=4326,max_length=40, blank=True,null=True) 
    objects             = GeoManager()

但是在调试过程中,运行过滤器命令qset后会导致

transformedLocation = loggedInEmployer.location.transform(32148, clone=True)
qset = modelEmployee.objects.filter(location__dwithin=(transformedLocation, D(mi=200)))

我相信这是因为200度不是度数。我的问题是,要使这项工作可行,我有什么选择?我需要将200英里转换为度吗?我该怎么办?

0 个答案:

没有答案