开发者

ImageModel form problem

开发者 https://www.devze.com 2022-12-15 21:25 出处:网络
I\'m trying to upload an image from a form. I\'m using Ima开发者_如何学CgeModel with the User as a foreign key, I\'m having trouble with the form . any help will be highly appreciated, please, thanksM

I'm trying to upload an image from a form. I'm using Ima开发者_如何学CgeModel with the User as a foreign key, I'm having trouble with the form . any help will be highly appreciated, please, thanks


Make sure your form tag contains enctype="multipart/form-data" and that you bind your form to request.POST, request.FILES

views.py:

some_view(request):
    if request.POST:
        form = myForm(request.POST, request.FILES)
        ....

template.html:

<form method='POST' enctype='multipart/form-data'>
...
0

精彩评论

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