[ACCEPTED]-Django Imagefield not working properly via ModelForm-django-models

Accepted answer
Score: 107

Well I feel like an idiot. In order for 8 Django to be able to process uploaded files, you 7 need to pass the request.FILES variable 6 to the form (makes sense, right?!)

In my 5 case the following line goes from:

f = AdminEditForm(request.POST, instance = company)


f = AdminEditForm(request.POST, request.FILES, instance = company)

Another 4 thing to check (if you run into something 3 like this in the future) is that your form 2 is multipart. Your <form> tag should look something 1 like this:

<form enctype="multipart/form-data" method="post" action="">
Score: 0

This happened to me because I was missing 2 the "name" attribute for the file 1 input.

More Related questions