File upload with Django: Invalid form

人走茶凉 提交于 2019-12-06 14:21:32
Erik Forsberg

Not entirely sure on this, but I would guess that since you've named your form fields file and title in the definition of the UploadFileForm class, the name attribute of your form fields in the html has to match that, i.e. the file upload field has to be named "file", and there also has to be a "title" field.

I'd recommend checking out https://docs.djangoproject.com/en/dev/topics/forms/ where there are examples on how to render the form automatically, or semi-automatically. Once you have it working with the automatically rendered form, you can customize it to your needs.

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