Does anyone have any simple code samples for Django + SWFUpload? I have it working perfectly in my PHP application but Django is giving me headaches.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unfortunately I can’t give you any very detailed code samples, but I have quite a bit of experience with working with SWFUpload + Django (for a photo sharing site I work on). Anyway, here are a few pointers that will hopefully help you on your quest for DjSWF happiness 🙂
You’ll want to use the cookies plugin (if of course you are using some sort of session-based authentication [like
django.contrib.auth, and care who uploaded what).The cookies plugin sends the data from cookies as POST, so you’ll have to find some way of getting this back into
request.COOKIES(process_requestmiddleware that looks for asettings.SESSION_COOKIE_NAMEinrequest.POSTon specific URLs and dumps it intorequest.COOKIESworks nicely for this 🙂Also, remember that you must return something in the response body for SWFUpload to recognize it as a successful upload attempt. I believe this has changed in the latest beta of SWFUpload, but anyway it’s advisable just to stick something in there like ‘ok’. For failures, make use of something like
HttpResponseBadRequestor the like.Lastly, in case you’re having trouble finding them, the uploaded file is in
request.FILES🙂If you have anything perplexing I haven’t covered, feel free to post something more detailed and I’ll be happy to help.