如何在 django-geoposition 中显示管理面板

How to show the admin panel in django-geoposition

今天我决定使用 django-geosposition 应用程序在我的项目中显示一些地图。问题是,在阅读 github 上的文档时,我仍然不知道我应该在 admin.py 上写什么,这样我才能添加一些地图。有人可以帮忙吗?

文档:GitHub of django-geoposition

根据文档,您只需在属性中添加 GeopositionField:

from django.db import models
from geoposition.fields import GeopositionField

class YourModel(models.Model):
    name = models.CharField(max_length=100)
    map_field = GeopositionField()

因此,当您转到管理员的模型页面时,您可以看到一张地图,您可以搜索位置并获取经纬度。

如果您想允许通过点击地图选择位置,只需在 settings.py 上添加几行:

GEOPOSITION_MARKER_OPTIONS = { 'cursor': 'move' }

https://github.com/philippbosch/django-geoposition

就这些了。