Я попытался наивно добавить его к admin.py
, как обычно.
from django.contrib.gis import admin
from project.models import ProjectMap
admin.site.register(ProjectMap, admin.OSMGeoAdmin)
Я попытался указать виджет:
content_panels = Page.content_panels + [
FieldPanel('location', widget='django.contrib.gis.forms.widgets.OSMWidget'),
]
Но он по-прежнему показывает спутниковое изображение по умолчанию из GeoModelAdmin.
Вот основные модели, с которыми я работаю.
class ProjectPage(Page):
date = models.DateField("Post date", null=True)
body = RichTextField(blank=True)
def main_image(self):
gallery_item = self.gallery_images.first()
if gallery_item:
return gallery_item.image
else:
return None
search_fields = Page.search_fields + [
index.SearchField('body'),
]
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('date'),
], heading="Project information"),
MultiFieldPanel([
FieldPanel('body', classname="full"),
], heading='Project'),
InlinePanel('gallery_images', label="Gallery images"),
InlinePanel('project_map', label="Project location")
]
class ProjectMap(Orderable):
page = ParentalKey(ProjectPage, related_name='project_map')
city = models.CharField(blank=True, max_length=250)
address = models.CharField(blank=True, max_length=250)
country = models.CharField(blank=True, max_length=250)
location = PointField(blank=True, null=True)
content_panels = Page.content_panels + [
MultiFieldPanel([
FieldPanel('city'),
FieldPanel('address'),
FieldPanel('country'),
FieldPanel('location'),
], heading="Location")
]
И документация, которой я следую:
widget
дляFieldPanel
должен быть объектом или классом виджета, а не строковым путем — можете ли вы попробоватьfrom django.contrib.gis.forms.widgets import OSMWidget
, а затемFieldPanel('location', widget=OSMWidget)
? - person gasman   schedule 18.10.2017