我正在尝试实现django地图小部件
https://github.com/erdem/django-map-widgets
但是没有出现地图,我在浏览器控制台中有这个
Uncaught ReferenceError: DjangoGooglePointFieldWidget is not defined
在设置中。py,我有
INSTALLED_APPS = [
...
'mapwidgets',
]
MAP_WIDGETS = {
"GoogleStaticMapWidget": (
("zoom", 15),
("size", "320x320"),
),
"GoogleStaticMapMarkerSettings": (
("color", "green"),
),
"GOOGLE_MAP_API_KEY": "AIzaSyA1fXsJSKqZH_Bl9d9wueJMlpXd-6tEJy0"
}
在我的模型中。py公司
class CompanySettingEdit(forms.ModelForm):
display_companyname = forms.CharField(label='Display Company Name', max_length=50, required=True)
class Meta:
model = Company
fields = ("display_companyname","location_point")
widgets = {
'location_point': GooglePointFieldWidget,
}
更新:
设置中的我的静态文件配置。py公司
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "../projectapp/static"),
)
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_DIR, '../../../static_root')
运行python manage之后。py collectstatic,静态文件复制到另一个目录static\u root-
https://imgur.com/a/TmhYr
. 请注意,mapwidgets目录不在原始项目静态目录中。我正在运行开发,我注意到引导静态文件使用的是静态目录中的文件,而不是static\u root
我错过什么了吗?我需要加载模板中的任何内容吗?