When editing an object in django the ImageField is not populated

有些话、适合烂在心里 提交于 2019-12-04 15:13:26

I believe the answer lies in the fact that the file input field, when it displays a value, displays the local path to the file on the user's computer that was selected. This value is not saved in Django anywhere so Django can't and won't display this value in the form when editing.

What you need to do is print each field individually in the template instead of printing the form as a whole. Then, with your thumbnail field, show the currently selected thumbnail as an actual image on the page and use the file input field to allow the user to upload a new image.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!