Django newbness: ImageField and the missing request.FILES data
I’ve created a new category for stuff like this that I discover while writing Django stuff, and this would be the first post in that category (I’ll go back through and assign all my old applicable posts to this Django category, too).
Anyway, I was having trouble with an ImageField in a model. I created a ModelForm that used this model to map out the associated form fields, including one with a file input widget for the ImageField. When it came time for me to use this with a template, I had all the fields in place, the proper directories had the proper permissions and all the settings were set, and I tried to upload the image. The form validated and it acted like nothing happened, like no picture was ever attached. This had me frustrated.
So I tried inserting an assert False to see what my locals() were. There was nothing in request.FILES, where there should have been. After some Googling and trying to find the right way to phrase my Google search, I found my solution here.
Apparently my form tag didn’t have one critical attribute:
enctype="multipart/form-data"
After I had that jewel, all was golden.

