开发者

django file upload in 2 steps

I want to upload a file in 2 steps. First I want to upload it and show the errors and on the second step I want actually to save the file data in the database. So I made a simple form and my problem is how to pass the same file to the form on the second step? I mean how to insert request.FILES data in the same form again. Or maybe there is a better way? Thanks, Arshavski Ale开发者_JAVA技巧xander.


First,

Using django's inbuilt File field, you don't store the files in the database, but in the filesystem. You only store the metadata in the database.

Next,

If you want to validate a file input, you can use the standard form validation, where you define the the clean_file_field_name and raise the forms.ValidationError django automatically does the "showing of the page until proper input is provided" for you.

That is the right way of doing it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜