settings.py
MEIDA_URL = '/pic/' MEDIA_ROOT = os.path.join(REPOSITORY_ROOT, 'pic/') STATIC_URL = '/static/' STATIC_ROOT = os.path.join(REPOSITORY_ROOT, 'static/') STATICFILES_DIRS = ( os.path.join(BASE_DIR, "static"), '/var/www/static/', )
urls.py
from django.conf.urls import include, url from django.contrib import admin from django.conf import settings from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.conf.urls.static import static urlpatterns = [ ...... ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) urlpatterns += staticfiles_urlpatterns()
models.py
class UserProfile(models.Model): user = models.OneToOneField(User) tagcloud = models.ImageField(upload_to ='rapper/')
topicWords.py
d = path.dirname("/rapper/") wc = WordCloud(background_color="white", max_words=2000, font_path='WeibeiSC-Bold.otf') # generate word cloud wc.generate_from_frequencies(word_tag) # save to the "rapper/", right? wc.to_file(path.join(d,"rapper1.png")) userprofile.tagcloud = "rapper/rapper1.png" userprofile.save()
source share