【Django】解决上传图片不显示问题
在项目文件夹中新建media目录
在settings.py中
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
在urls.py中
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
注意:文档上说明这不适合生产环境!