Ticket #35312: urls.py

File urls.py, 770 bytes (added by yudhiwidyatama, 8 months ago)

this is my change suggestion in contrib/staticfiles/urls.py

Line 
1from django.conf import settings
2from django.conf.urls.static import static
3from django.urls import get_script_prefix
4from django.contrib.staticfiles.views import serve
5import sys
6urlpatterns = []
7
8
9def staticfiles_urlpatterns(prefix=None):
10 """
11 Helper function to return a URL pattern for serving static files.
12 """
13 if prefix is None:
14 prefix = settings.STATIC_URL
15 tmp_script_prefix = get_script_prefix()
16 if len(tmp_script_prefix) > 1 and prefix.startswith(tmp_script_prefix):
17 l1 = len(tmp_script_prefix)
18 oldprefix = prefix
19 prefix = prefix[l1:]
20 return static(prefix, view=serve)
21
22
23# Only append if urlpatterns are empty
24if settings.DEBUG and not urlpatterns:
25 urlpatterns += staticfiles_urlpatterns()
Back to Top