Python 如何使用django正确显示用户生成的图像?
我正试图上传一张用户生成的图片,然后显示在我的django web应用程序中。图像正在上载到服务器,但我无法显示它 models.py 设置.pyPython 如何使用django正确显示用户生成的图像?,python,django,settings,models,imagefield,Python,Django,Settings,Models,Imagefield,我正试图上传一张用户生成的图片,然后显示在我的django web应用程序中。图像正在上载到服务器,但我无法显示它 models.py 设置.py 例如,假设我上传了一个名为Finland.gif的文件。我可以看到上传的文件。但是,当我查看源代码时,我看到图像的源代码是“www.foo.com/accounts/profile/images/Finland.gif”,而不是静态图像url,它应该是”http://user.webfactional.com/static/images/Finlan
例如,假设我上传了一个名为Finland.gif的文件。我可以看到上传的文件。但是,当我查看源代码时,我看到图像的源代码是“www.foo.com/accounts/profile/images/Finland.gif”,而不是静态图像url,它应该是”http://user.webfactional.com/static/images/Finland.gif". 有没有关于如何解决这个问题的建议?刚刚解决了。。。我需要包括:
http://user.webfactional.com/static/{{userprofile.image}
userprofile.image.url
提供图像的完整url您可以显示用于显示图像的代码吗?@Rakesh
image = models.ImageField(blank=True, null=True, max_length=255, upload_to="images/")
MEDIA_ROOT = '/home/user/webapps/static/'
MEDIA_URL = 'http://user.webfactional.com/static/'