add Image Field in model

25 views
Skip to first unread message

omar ahmed

unread,
Mar 12, 2019, 9:20:43 AM3/12/19
to Django users
hello
i want to add image field in my model
i typed :
 image = models.ImageField()
but :
 Cannot use ImageField because Pillow is not installed

Suresh Kannan

unread,
Mar 12, 2019, 9:24:04 AM3/12/19
to django...@googlegroups.com
--
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...@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/6101b636-925a-4f22-9637-13678d2ecaf0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

omar ahmed

unread,
Mar 12, 2019, 9:28:34 AM3/12/19
to Django users
ok i will try it ... thank you

Amitesh Sahay

unread,
Mar 13, 2019, 4:58:50 AM3/13/19
to Django users
Hello Omar, 

You need to install "pillow" python module in order to work with image files.

Regards,
Amitesh Sahay
91-750 797 8619


omar ahmed

unread,
Mar 13, 2019, 8:24:51 AM3/13/19
to Django users
i installed it
thanks Amitesh
but what about creating image field in model

Aayush Bhattarai

unread,
Mar 25, 2019, 12:28:43 PM3/25/19
to Django users
Dude Use this code

image = models.ImageField(upload_to='media/') 
and also make sure to install pillow

Amitesh Sahay

unread,
Mar 26, 2019, 6:51:43 AM3/26/19
to Django users
Hello Omar, 

When creating a model you need to use "ImageField"

example

abc = models.ImageFields()

I hope thats what you are looking for. If you have any specific requirements do let me know.
Sorry for the delayed response.

Regards,
Amitesh Sahay


Reply all
Reply to author
Forward
0 new messages