2016-07-21 84 views
0

我想用在我的模型領域之一FilerImageField並希望用戶管理區以外的編輯,但是當我嘗試加載它,小部件無法正常工作而在瀏覽器控制檯,我得到和產生的JavaScript錯誤:Django的文件管理器FilerImageField如何使用小部件外管理

Uncaught TypeError: Cannot read property 'jQuery' of undefined 

在這裏:

  <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') 

領域似乎是這樣的:

Field

你有任何想法,爲什麼我不能使用這個字段插件的管理之外?我需要爲此設置一些配置嗎?

謝謝:)

+0

您好帕特里夏,我已經回答了GitHub的車票。 – Paulo

+0

@Paulo你能發佈一個鏈接嗎? – tated

+0

其實我跟蹤下來 - 爲那些按照順序,簡單的答案是,它不支持作爲額外的管理員上傳控件:https://github.com/divio/django-filer/issues/894 – tated

回答

0

首先,加{{ form.media }}在HTML文件中,只是標籤<form>{% csrf_token %}後。然後如您在Github issue:https://github.com/divio/django-cms/issues/6028上的SteinRobert所解釋的那樣,在您的forms.py的ModelForm中擴展媒體類。它工作完美!謝謝Stein!