Friday, November 20, 2015

Problem of saving and uploading image with DJANGO

Here is what I desire:
Now I have generated a image of world cloud for a specific user(so that each user will have a unique image), but the problem here is how can I storage the image and display it? 
For instance, in the topicWords.py where I generate the image, i have wc = WordCloud(background_color="white", max_words=2000) wc is the image. And what should I do to store it if I want to add it in a imagefiled for user profile? 
In my models.py: 
class UserProfile(models.Model):
user = models.OneToOneField(User)
tagcloud = models.ImageField(upload_to ='/pic/')
And how to call it on the views.py?
Lastly, how to display it on html?
Besides, it seems that I need the setting of MEDIA_ROOT and MEDIA_URL, how should I set them and add in the urls.py?
Hope it would not be too much for so many questions! I am new to Django and Thanks in advance!

--
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-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/aa0c546e-2123-4266-81ec-b3c0c4bb5be1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment