Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Ajax with demo #1

Closed
mtmarsh2 opened this issue Jan 26, 2014 · 4 comments
Closed

Using Ajax with demo #1

mtmarsh2 opened this issue Jan 26, 2014 · 4 comments
Labels

Comments

@mtmarsh2
Copy link

Hi, I am confused as to where the django-ajax-uploader is being used in this demo. When I add an image to the demo, the post request isn't sent through ajax, right? Because the url changes after the save button is clicked, which means the form isnt using ajax, right?

@archatas
Copy link
Owner

The django-ajax-uploader is used to upload an image by Ajax to the server and get the temporary path of that image. As you see, the upload happens immediately, when you select an image from your filesystem, NOT when you click on the submit button.

The form itself in this example doesn't use Ajax. It just submits the temporary image path and then the image is copied from the temporary upload path to its final destination. If you need Ajaxified version of the form with the hidden field too, it is not too difficult to modify the view and add some Ajax handling javascript for the form.

@mtmarsh2
Copy link
Author

Ahh okay that makes sense, so when the user adds a image from their filesystem, the image is immediately sent to the server, which is the ajax part, thanks for clearing that up

@mtmarsh2
Copy link
Author

One more question: How does the system know what to do when a user selects a picture, but then doesnt actually do a post request? The image should then be deleted from the filesystem, since the user for example, clicked the back button, right?

@archatas
Copy link
Owner

This app example doesn't cover that, but there could be a management command run by a cron job which deletes all temporary files in the directory which are older than (let's say) a day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants