Sunday, November 22, 2015

Re: Problem of saving and uploading image with DJANGO

And how to call it on the views.py?

Create a  model form,  https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#module-django.forms.models

Lastly, how to display it on html?

for instance you can do  <img src="{{ object.tagcloud.url}}"  ... >


how should I set them and add in the urls.py?

For develop environment static file is set by default, but for production you need to configure your web server (e.g apache, nginx).

see https://docs.djangoproject.com/en/1.8/howto/static-files/



2015-11-20 23:24 GMT-06:00 rylanlee <s1107239@s.ied.edu.hk>:
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.



--
"La utopía sirve para caminar" Fernando Birri


--
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/CAG%2B5VyOKYwc%2B7CtNQ7pjhY70eVHoe9ehAuJn7Lb9qoY4gfzGZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment