增加media文件配置
1.增加media文件配置
1.1 syl/settings.py
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media') #
/teach/shiyanlou_project/syl/media
1.2 syl/urls.py
from django.conf.urls.static import static
from syl import settings
urlpatterns = [
]
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
1.3 测试静态文件访问
-
放一个测试图片到 syl/media/linux.jpg 中
http://192.168.56.100:8888/media/linux.jpg
-
测试结果