I have a modelForm and imagefield in model. Everything seems ok in form.
I put a debugger in save method of form.
self.data appears like below
<QueryDict: {u'city': [u'19105'], u'surname': [u'VARGI'], u'name': [u'Tuna'], u'image': [u'996884_10151559653258613_1077262085_n.jpg'], u'user': [u'1'], u'interest': [u''], u'csrfmiddlewaretoken': [u'pHAfb5EJBc7N3Xa8YxTQKRrSDeLdBugh'], u'biography': [u'asdasdasdasdasda']}>
and self.is_valid() is True and self.errors is empty
but my self.clean() is
{'city': <City: Ankara, Ankara, Turkey>, 'is_featured': False, 'biography': u'asdasdasdasdasda', 'surname': u'VARGI', 'name': u'Tuna', 'image': None, 'is_active': False, 'user': <Member: tuna>, 'interest': [], 'email': u'', 'categories': []}
image come as None. Any ideas ?
By the way, i can add an image from django-admin
Make sure you have enctype="multipart/form-data"
set on your html tag. And make sure you pass request.FILES
into the form. For example: form = MyAwesomeForm(request.POST, request.FILES)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.