class Photo(models.Model):
file = models.ImageField(upload_to='%Y/%m/%d', blank=True,null=True)
<form method="post" enctype="multipart/form-data" " >
{% csrf_token %}
<input type="file" id="photo_id" name="file">
<input type="submit" value=" send image" />
</form>
from PIL import Image
def save_photo(request):
_photo, created = models.Photo.objects.get_or_create(pk=1)
if request.method == 'POST':
photo = request.FILES.get('file')
image = Image.open(photo)
cropped_image = image.crop((100, 100, 200, 200))
resized_image = cropped_image.resize((200, 200), Image.ANTIALIAS)
_photo.file = resized_image
_photo.save()
return HttpResponse("your image has been saved")
'Image' object has no attribute '_committed'
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/362887c4-6b41-47e2-a9f5-f4a129b2538d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Regards,Andréas
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7be760c5-b5e3-4066-bb27-e953e829d68c%40googlegroups.com.
On Monday 03 July 2017 03:09:56 shahab emami wrote:
> hello
>
> i have a question and i cant find answer with search.