Skip to content
Snippets Groups Projects
Commit 3debd75f authored by Tobias Mieves's avatar Tobias Mieves :sparkles:
Browse files

fix: Configure Django to serve static and media files itself

For small sites this is ok. For bigger sites a file server such as nginx
or apache should be used.
parent baf20036
No related branches found
No related tags found
1 merge request!19Configure Django to serve static and media files itself
......@@ -13,14 +13,15 @@ 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.urls.static import static
from django.contrib import admin
from django.urls import path, include
from core import settings
from django.contrib import admin
from django.urls import path, include, re_path
from django.views.static import serve
urlpatterns = [
path("admin/", admin.site.urls),
path("accounts/", include("django.contrib.auth.urls")),
path("", include("{{app_to_install}}.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
re_path(r"^media/(?P<path>.*)$", serve, {"document_root": settings.MEDIA_ROOT}),
re_path(r"^static/(?P<path>.*)$", serve, {"document_root": settings.STATIC_ROOT}),
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment