평소와 같이 admin.py
에 자연스럽게 추가하려고했습니다. 기본 GeoModelAdmin을 OSMGeoAdmin으로 변경하십시오.
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'),
]
을하지만 STIL 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")
]
그리고 문서 내가 다음하고는 :
FieldPanel''에'widget' 인수가 위젯 객체가 될 필요가 또는를 클래스가 아닌 문자열 경로 -'django.contrib.gis.forms.widgets import OSMWidget'과'FieldPanel ('location', widget = OSMWidget)'을 시도 할 수 있습니까? – gasman