开发者

Prepopulating a Django FileField

开发者 https://www.devze.com 2023-01-17 15:41 出处:网络
I wanted to know how is it possible in django to bind an already uploaded file (stored in the file system of server) to a Model FileField. This way I want to have my edit page of that model to prepopu

I wanted to know how is it possible in django to bind an already uploaded file (stored in the file system of server) to a Model FileField. This way I want to have my edit page of that model to prepopulate the FileField with this file.

开发者_开发技巧

Thanks


Well I found the answer. It was quite easy actually. you just need to set the FileField value to some string and it will point to that file.

The point is that the path specified should be correct otherwise you get a 404 error when trying to access it.

0

精彩评论

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