mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2025-07-13 09:32:26 +03:00
Added static files URL for runserver-level/best performance
* The reason there was a degraded performance was because we're using Gunicorn itself as a local tester. So we needed to add the staticfiles urls
This commit is contained in:
parent
125ffec243
commit
e6b800d985
|
@ -7,6 +7,9 @@ from django.views.generic import TemplateView
|
||||||
{%- if cookiecutter.use_drf == 'y' %}
|
{%- if cookiecutter.use_drf == 'y' %}
|
||||||
from rest_framework.authtoken.views import obtain_auth_token
|
from rest_framework.authtoken.views import obtain_auth_token
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
{%- if cookiecutter.use_async %}
|
||||||
|
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
path("", TemplateView.as_view(template_name="pages/home.html"), name="home"),
|
||||||
|
@ -20,6 +23,11 @@ urlpatterns = [
|
||||||
path("accounts/", include("allauth.urls")),
|
path("accounts/", include("allauth.urls")),
|
||||||
# Your stuff: custom urls includes go here
|
# Your stuff: custom urls includes go here
|
||||||
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
{% if cookiecutter.use_async %}
|
||||||
|
# Static file serving when using Gunicorn + Uvicorn for local development
|
||||||
|
if settings.DEBUG:
|
||||||
|
urlpatterns += staticfiles_urlpatterns()
|
||||||
|
{% endif %}
|
||||||
{% if cookiecutter.use_drf == 'y' -%}
|
{% if cookiecutter.use_drf == 'y' -%}
|
||||||
# API URLS
|
# API URLS
|
||||||
urlpatterns += [
|
urlpatterns += [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user