我尝试在django中设置leaflet_config,如下所示:
LEAFLET_CONFIG = {
'SRID' : 3857,
'DEFAULT_CENTER': (-3.87, 178.59),
'DEFAULT_ZOOM': 14,
'MIN_ZOOM': 3,
'MAX_ZOOM': 20,
'RESET_VIEW': False,
'TILES': [('Aerial Imagery', 'http://otile{s}.mqcdn.com/tiles/1.0.0/osm/{z}/{x}/{y}.png', {'type': 'sat', 'ext': 'jpg','attribution': 'Data CC-By-SA by <a href="http://openstreetmap.org/" target="_blank">OpenStreetMap</a>, Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a>','subdomains': ['1','2','3','4']})],
}
这是admin.py
from django.contrib import admin
from .models import Track
from leaflet.admin import LeafletGeoAdmin
admin.site.register(Track, LeafletGeoAdmin)
并且在django管理地图图层中不显示。我尝试使用开发者工具网络秀这样。
Request URL:http://otile2.mqcdn.com/tiles/1.0.0/osm/14/13453/8352.png
Request Headers
Provisional headers are shown
Accept:image/webp,*/*;q=0.8
Referer:http://127.0.0.1:8000/admin/fleet/track/1/
User-Agent:Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36
可以帮助解决这个问题吗?
答案 0 :(得分:1)
老问题,但是我通过在myapp\admin.py
中注册admin.site时通过传递选项来解决了这个问题:
from django.contrib.gis import admin
from leaflet.admin import LeafletGeoAdmin
from .models import Project, FPV
admin.site.register(
Project, #<-- this is a model
LeafletGeoAdmin,
settings_overrides = {
'DEFAULT_CENTER': (59.334591, 18.063240),
'DEFAULT_ZOOM': 10,
'TILES': [('','//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png','')],
}
)