我想上传用户生成的图像,然后显示在我的django网络应用程序。图像上传到服务器,但我无法显示它。如何使用django正确显示用户生成的图像?
models.py
image = models.ImageField(blank=True, null=True, max_length=255, upload_to="images/")
settings.py
MEDIA_ROOT = '/home/user/webapps/static/'
MEDIA_URL = 'http://user.webfactional.com/static/'
举个例子,说我上传我的文件命名Finland.gif。我可以看到上传的文件。然而,当我看到源代码时,我将该图片的源代码视为“www.foo.com/accounts/profile/images/Finland.gif”,而不是静态图片url,它应该是“http://user.webfactional .COM /静态/图片/ Finland.gif”。有关如何解决这个问题的任何建议?
ü可以显示用于显示图像的代码? – Rakesh
@Rakesh – sharataka