【发布时间】:2015-07-18 01:39:12
【问题描述】:
我刚刚将 django-admin-bootstrapped 添加到我的项目中。几乎一切都很好。 实际上有两个小错误我想知道如何解决。 第一个是关于 DateField 和 TimeField :当我在 django-admin-bootstrapped 下时没有日期/时间选择器。当我检查源代码时,没有生成关于两个选择器的源代码。当我停用 django-admin-bootstrapped 时,缺少的是:
在 DateField 旁边:
<span class="datetimeshortcuts">
<a href="javascript:DateTimeShortcuts.handleCalendarQuickLink(0, 0);">Today</a> |
<a href="javascript:DateTimeShortcuts.openCalendar(0);"
id="calendarlink0"><img src="/static/admin/img/icon_calendar.gif" alt="Calendar">
</a></span>
TimeField 旁边:
<span class="datetimeshortcuts">
<a href="javascript:DateTimeShortcuts.handleClockQuicklink(1, -1);">Now</a> |
<a href="javascript:DateTimeShortcuts.openClock(1);"
id="clocklink1"><img src="/static/admin/img/icon_clock.gif" alt="Clock">
</a></span>
第二个是关于 PointField(我正在使用 postGis),没有 django-admin-bootstrapped,我的字段很好,但是当它被引导时,我在 OpenLayer.js 上出现错误:
OpenLayers.js:679 Uncaught TypeError: Cannot read property 'w' of null
那么,两个问题(使用 django 1.8 和 django-admin-bootstrapped):
1- 如何在管理界面中恢复日期/时间选择器? 2- 如何在管理界面中恢复我的 PointField 地图选择器?
谢谢大家。 (这里是 github 上的相同问题(1):https://github.com/django-admin-bootstrapped/django-admin-bootstrapped/issues/168 但只有外部工作区(我更喜欢本地工作区))
编辑:来自我的站点包:./django/contrib/gis/admin/options.py 我直接把调用 OpenLayer.js 的那一行改成了 OpenLayer.debug.js 给你提供更多信息。
在 OpenLayer.debug.js 第 40008 行是错误的来源:
setMap: function(map) {
OpenLayers.Layer.prototype.setMap.apply(this, arguments);
if (!this.renderer) {
this.map.removeLayer(this);
} else {
this.renderer.map = this.map;
var newSize = this.map.getSize();
40008-> newSize.w = newSize.w * this.ratio;
newSize.h = newSize.h * this.ratio;
this.renderer.setSize(newSize);
}
},
这里是 OpenLayer.debug.js 上的整个 JS 追溯 + GeoDjango 的索引:
Uncaught TypeError: Cannot read property 'w' of null ==> OpenLayers.debug.js:40008
newSize.w = newSize.w * this.ratio;
OpenLayers.Layer.Vector.OpenLayers.Class.setMap ==> OpenLayers.debug.js:8349
layer.setMap(this);
OpenLayers.Map.OpenLayers.Class.addLayer ==> (index):614
geodjango_gps_point.map.addLayer(geodjango_gps_point.layers.vector);
geodjango_gps_point.init ==>(索引):677(匿名函数)
<script type="text/javascript">geodjango_gps_point.init();</script>
【问题讨论】:
标签: javascript python twitter-bootstrap django-admin postgis