dimanche 22 novembre 2015

How to display a image which is generated in the backend with Django

I am new to django and I am confused with the image display problem. Now I have a image of word-cloud generated in the backend(let's say, topicWords.py) and I don't know hot to deal with it. (1) How can I store it in the image field of model UserProfile? In the models.py, I have:

class UserProfile(models.Model):
user = models.OneToOneField(User)
tagcloud = models.ImageField(upload_to ='rap_song/raptle/pic/')

Is it right to directly do like:

user.userprofile.tagcloud = wc #wc is the image generated

(2) What should the setting of MEDIA_ROOT and MEDIA_URL be?

(3) How should I display it in the .html?

<img src = "???">

Thank you very much!




Aucun commentaire:

Enregistrer un commentaire