I have a form, with a bunch of fields, and then I have a:
profile_image=forms.ImageField(required=False)
The problem si that after the form.is_valid() check,
form.cleaned_data.get('first_name')
for example DOES return the actual name, however,
form.cleaned_data.get('profile_image')
DOES NOT return anynthing.
In the print(request.POST) output, i get
u'profile_image': [u'02 Portfolio Page.jpg']
but in the print(form.cleaned_data) i get:
'profile_image': None
Why is the file lost at the is_valid check? What should I do?
UPDATE:
class NewChickForm(forms.Form):
first_name = forms.CharField()
last_name = forms.CharField()
profile_image=forms.ImageField(required=False)
def do_save(self):
u = Subject(
first_name = self.cleaned_data.get('first_name'),
last_name = self.cleaned_data.get('last_name'),
profile_image = self.cleaned_data.get('profile_image'),
)
print(self.cleaned_data)
u.save()
return u
and
s = Subject()
form = NewChickForm(request.POST) # 1)do i add here `request.FILES` ?
if form.is_valid():
s = form.do_save()
# 2) s.profile_image = form.cleaned_data.get('profile_image')?
Even if i do #1) and #2), i still get NONE