我想使用FilerImageField
在我的模型字段之一中,并希望用户在管理区域之外进行编辑,但是当我尝试加载它时,小部件无法正常工作,并且在浏览器控制台中,我在生成的 javascript 中收到错误:
Uncaught TypeError: Cannot read property 'jQuery' of undefined
In here:
<script type="text/javascript" id="id_featured_image_javascript">
django.jQuery(document).ready(function(){
var plus = django.jQuery('#add_id_featured_image');
if (plus.length){
plus.remove();
}
// Delete this javascript once loaded to avoid the "add new" link duplicates it
django.jQuery('#id_featured_image_javascript').remove();
});
</script>
我的模型中的字段定义如下:
article_image = FilerImageField(db_column="ARTICLE_IMAGE",
verbose_name=_('Article Image'),
related_name='IPP_ARTICLE_IMAGE')
该字段显示如下:
您知道为什么我不能在管理员之外使用此字段小部件吗?我需要为此设置一些配置吗?
谢谢 :)
首先,添加{{ form.media }}
在你的 html 文件中,就在标签之后<form>
and {% csrf_token %}
。然后扩展您的媒体课程ModelForm
正如 SteinRobert 在 Github 问题上所解释的 forms.py 的内容:https://github.com/divio/django-cms/issues/6028 https://github.com/divio/django-cms/issues/6028。它工作完美!谢谢斯坦因!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)