我想上傳用戶生成的圖像,然後顯示在我的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