7

How do I invoke the upload widget outside Admin? Using the standard form below does not work. The widget is corrupted.

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 absolutely no reference to this in the documentation. How can I upload photos outside 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: "Uncaught ReferenceError: django is not defined"

Could it be that I need to know what css to include and what javascript files to load?

caliph
  • 1,389
  • 3
  • 27
  • 52
  • What do you mean by corrupted? – Sayse Dec 07 '15 at 19:49
  • There is a javascript error. And a new text input field is visible. A click on the magnifier does not open a pop-up, but moves directly to the filer folder window. a selection of a image is not possible because the control to do so is missing. I will post the generated html code. – caliph Dec 07 '15 at 20:04
  • I too want to know this, unfortunately the google group seems all but dead and there is no documentation as you mentioned. It is a great plugin I am sad it seems like it isn't supported anymore. – Codejoy May 17 '16 at 16:50
  • @caliph did you solve it? – patricia Jul 21 '16 at 18:27
  • Unfortunately the app isn't designed to be used outside the admin, see https://github.com/divio/django-filer/issues/894 – tdsymonds Nov 04 '16 at 14:06
  • Check if this helps http://stackoverflow.com/a/43380918/977622 – psychok7 Apr 12 '17 at 22:57

1 Answers1

3

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

openHBP
  • 627
  • 4
  • 11