1

I am trying to implement dropzone in my project to upload multiple images. But apparently, when I call dropzone.create(action=''), I keep getting the error that the url is not build. Below are the implementation details I did.

This is my css code filename: template.html.j2

{% block style %}
{{ dropzone.load_css() }}
{{ dropzone.style('border: 2px dashed #0087F7; margin: 10%; min-height: 400px;') }}
{% endblock %}

This is the import of dropzone:

{% block scripts %}
<script src="{{url_for('static', filename='jsfiles/dropzone.js')}}"></script>
{% endblock %}

The Body part:

{{ dropzone.create(action=url_for('folder1.upload, id=user.id'))}}
{{ dropzone.load_js() }}
{{ dropzone.config() }}

This is my function : File name:user.py

@inspection.route('/users/<int:user__id>', methods=['GET', 'POST'])
def upload(id):
    //Some Code
    if form.validate_on_submit() and 'photo' in request.files:
      for f in request.files.getlist('photo'):
         filename = secure_filename(f.filename)
         print(filename)

    return render_template('folder/user_details.html.j2')

The folder structure is as below:

  • Folder1
    • user.py
  • Templates
    • template.html.j2
  • app.py

It would be great if someone can point out why I keep getting this error.

Cannot build url for endpoint folder1.upload

1 Answer 1

0

Try this:

Body part

{{ dropzone.create(action=url_for('folder1.user.upload, pk=user.id'))}}
{{ dropzone.load_js() }}
{{ dropzone.config() }}

user.py

@inspection.route('/users/<int:pk>', methods=['GET', 'POST'])
def upload(pk):
     //Some Code
     if form.validate_on_submit() and 'photo' in request.files:
         for f in request.files.getlist('photo'):
             filename = secure_filename(f.filename)
             print(filename)

    return render_template('folder/user_details.html.j2')
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.