在管理 Django 面板中创建的地理点未正确显示在 html 中

Geographic point created in admin Django panel is not displayed correctly located in the html

提问人:Lesperguer 提问时间:10/24/2023 最后编辑:Lesperguer 更新时间:10/24/2023 访问量:13

问:

我用 postgis 创建了一个模型,并使用 Folium 渲染了模板。但是在渲染 html 时。地理点出现在不对应的地理区域中。我已经检查了 srid,从我所读到的内容来看,它们默认为 4326 或 WGS84。谁能帮我解决这个问题?

models.py

from django.contrib.gis.db import models
class Location(models.Model):name=models.CharField(max_length=250,verbose_name='nombre arbol')
punto=models.PointField()
    def str(self):
        return f"{self.punto}"`

views.py

from django.shortcuts import renderimport foliumfrom .models import *
def home(request):
    locations=Location.objects.all()initialMap=folium.Map(location=[-33.56919516402464, -70.81542789027874], zoom_start=18)
    for location in locations:    
        folium.Marker(location.punto ,popup='Arbol'+ location.punto ).add_to(initialMap)
    context={'map':initialMap._repr_html_(),'locations':locations}
    return render(request, 'survey/home.html',context)

admin.py

from django.contrib import adminfrom .models import * 
admin.site.register(Location)

错误点

这是点应该出现的地方

我需要知道我需要设置什么,以便这些点出现在我创建它们的地理上对应的位置(我从 Django 管理面板创建它们)

从 admnin 面板创建点

这是安装在我的 Venv 上的库

asgiref==3.7.2

布兰卡==0.6.0

证书FI==2023.7.22

字符集归一化器==3.3.1

Django==4.2.6

对开==0.14.0

GDAL @ file:///-/Downloads/GDAL-3.4.3-cp311-cp311-win_amd64.whl#sha256=f78861fb5115d5c2f8cf3c52a492ff548da9e1256dc84088947379f90e77e5b6

idna==3.4

金贾2==3.1.2

标记安全==2.1.3

numpy==1.26.1

psycopg2==2.9.9

请求数==2.31.0

sqlparse==0.4.4

tzdata==2023.3

urllib3==2.0.7

感谢您的帮助,非常感谢您抽出时间接受采访。

姜戈 folium

评论


答: 暂无答案