topic description
DEBUG = False cannot find the picture path, other style files can be loaded
setting.py file
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
DEBUG = False
STATIC_URL = "/static/"
if DEBUG:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
else:
STATIC_ROOT = os.path.join(BASE_DIR, "static")
MEDIA_URL = "/media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "static/media")
routing information
urlpatterns = [
...
path("summernote/", include("django_summernote.urls")),
path("archives/<str:year>/<str:month>", blog_views.archives, name="archives"),
path("category/<str:id>", blog_views.category, name="category"),
]
-sharp DEBUG = False
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
else:
urlpatterns += [
url(r"^static/(?P<path>.*)$", serve,
{"document_root": settings.STATIC_ROOT}),
]
Directory structure
the problems related to searching on the Internet have been tried but have not been solved. It can only be displayed normally when DEBUG = True
as a beginner, I don"t quite understand