Django-Filer: how to call a download widget outside the admin

How to call the download widget outside the administrator? Using the standard form below does not work. The widget is damaged.

forms.py class PhotoAdd(forms.ModelForm): class Meta: model = Photo fields = ('ImageFilerField',) views.py def photoadd(request): context={} context['form'] = PhotoAdd() render(request, 'template.html', context) template.html {{ form }} 

There is no reference to this in the documentation. How to upload photos outside the admin?

Edit: (added generated code from django above)

 <label for="id_doc_pic">Doc pic:</label> </th> <td> <span class="filerFile"> <img id="id_doc_pic_thumbnail_img" src="/static/filer/icons/nofile_48x48.png" class="quiet" alt="no file selected" /> &nbsp;<span id="id_doc_pic_description_txt"></span> <a href="/admin/filer/folder/last/?_to_field=file_ptr" class="related-lookup" id="lookup_id_doc_pic" title="Lookup"> <img src="/static/admin/img/icon_searchbox.png" width="16" height="16" alt="Lookup" /></a><img id="id_doc_pic_clear" class="filerClearer" src="/static/admin/img/icon_deletelink.gif" width="10" height="10" alt="Clear" title="Clear" style="display: none;" /><br /> <input class="vForeignKeyRawIdAdminField" id="id_doc_pic" name="doc_pic" type="text" /> <script type="text/javascript" id="id_doc_pic_javascript"> django.jQuery(document).ready(function(){ var plus = django.jQuery("#add_id_doc_pic"); if (plus.length){ plus.remove(); } django.jQuery('#id_doc_pic_javascript').remove(); }); </script> </span> 

Javascript error: "Untrained ReferenceError: django not defined"

Maybe I need to know what to enable css and which javascript files to download?

+6
source share
1 answer

First of all, add {{ form.media }} to your html file right after the <form> and {% csrf_token %} . Then extend the media class to ModelForm forms.py , as SteinRobert explained on the Github issue: https://github.com/divio/django-cms/issues/6028 . It works great! Thanks Stein!

+1
source

All Articles