Specify static, media files url

This commit is contained in:
jhyns 2023-05-16 21:48:59 +09:00
parent e65c78228d
commit 1d44edc456
2 changed files with 17 additions and 5 deletions

View File

@ -115,6 +115,12 @@ USE_TZ = True
# https://docs.djangoproject.com/en/4.2/howto/static-files/
STATIC_URL = "static/"
STATIC_ROOT = os.path.join(BASE_DIR, "static")
# Media files
MEDIA_URL = "media/"
MEDIA_ROOT = os.path.join(BASE_DIR, "media")
# Default primary key field type
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field

View File

@ -14,11 +14,17 @@ Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("admin/", admin.site.urls),
path("", include("market.urls")),
path("user/", include("user.urls")),
]
urlpatterns = (
[
path("admin/", admin.site.urls),
path("", include("market.urls")),
path("user/", include("user.urls")),
]
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
+ static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
)