GithubHelp home page GithubHelp logo

How to add args to upload view? about django-jfu HOT 4 CLOSED

alem avatar alem commented on July 16, 2024
How to add args to upload view?

from django-jfu.

Comments (4)

Alem avatar Alem commented on July 16, 2024

Hi Pavel,
the upload handler view is expected to receive form data, so if you
would like to include additional data (e.g. 'some_key') it would be
sensible to include it as form data rather than GET variables.

The jQuery File Upload fileupload function allows the inclusion of
additional form data in its POST requests. This functionality is
actively exploited by Django-JFU to supply Django with a valid CSRF
token. ::

    $('#fileupload').fileupload({

        formData: [
            { name: "csrfmiddlewaretoken", value: "{{ csrf_token }}"}
        ],

    ...

Please inspect the JS_INIT block in jfu/templates/jfu/upload_form.html
for an idea of what to modify.

Best Regards,
Zerse

On Tue, Sep 17, 2013 at 03:05:30AM -0700, Pavel Zaytsev wrote:

Hello!
How to use JFU for add variable in upload view?
For example, set some keys for YourUploadModel

@require_POST
def upload( request, some_key ):
    file = upload_receive( request )

    instance = YourUploadModel( some_key=some_key, sfile_field = file )
    instance.save()
...

Reply to this email directly or view it on GitHub:
#5

from django-jfu.

stelzzz avatar stelzzz commented on July 16, 2024

Hello Alem!
Big thanks! It`s work fine!
I set in my template:

{% block JS_INIT %}

        $('#fileupload').fileupload({

            formData: [
                { name: "csrfmiddlewaretoken", value: "{{ csrf_token }}"},
                { name: "some_id", value: "{{some.id}}"}

            ],


            {% block JS_OPTS %}
              autoUpload: true,
              maxNumberOfFiles: 10,
              sequentialUploads: true,
            {% endblock %}

        });
{% endblock %}

and in view

some_id=int(request.REQUEST.get('some_id'))

from django-jfu.

dhruvnarang avatar dhruvnarang commented on July 16, 2024

@stelzzz i was working on the same thing, do you know how to save the data in the database in upload function after retrieval from the template?

from django-jfu.

kartikdanidhariya avatar kartikdanidhariya commented on July 16, 2024

I tried but not working

from django-jfu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.