Reputation: 279
I'm trying to upload an image from a form. I'm using ImageModel with the User as a foreign key, I'm having trouble with the form . any help will be highly appreciated, please, thanks
Upvotes: 0
Views: 99
Reputation: 19082
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'>
...
Upvotes: 2