tags:

views:

34

answers:

1

Hello, 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

+1  A: 

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'>
...
Zach
<form method="POST" enctype="multipart/form-data"> would be better ;)
Tomasz Zielinski
Yes I believe that would be much better, I'll fix the answer
Zach