这是文件结构:
对myApp / mediafiles / 相片 我的网站/ 模板/ 我的网站/ 的index.html images.html profile.html
我的图片会使用以下设置保存到mediafiles/photos
:
TEMPLATE_DIRS, MEDIA_ROOT = [os.path.join(BASE_DIR, 'templates'), os.path.join(BASE_DIR, 'mediafiles')]
MEDIA_URL = '/mediafiles/'
我有四个urls
:
url(r'^$', views.index, name='index'),
url(r'^newimage/$', views.newImage, name='profile_photo'),
url(r'^user/(?P<user_name>\w+)/$', views.profile, name='profile'),
url(r'^books/(?P<book_id>\d+)/(?P<book_name>[-\w]+)/$', views.book_profile, name='book_profile'),
使用sorl-thumbnail
:
url(r'^$', views.index, name='index'),
#the image tag below display my image correctly
<img src=".{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
url(r'^newimage/$', views.newImage, name='profile_photo'),
#the image tag below display my image correctly
<img src="..{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
url(r'^user/(?P<user_name>\w+)/$', views.profile, name='profile'),
#all the image tags below display my image correctly
<img src="{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
<img src=".{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
<img src="...{{ im.url }}" width="{{ im.width }}" height="{{ im.height }}">
我做错了什么,我该怎么做?