Skip to content

Commit ec84efe

Browse files
committed
Simplified the development-mode static files serving, since we're now using the django staticfiles infrastructure.
- Legacy-Id: 9951
1 parent 4dc4c6d commit ec84efe

1 file changed

Lines changed: 22 additions & 11 deletions

File tree

ietf/urls.py

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# Copyright The IETF Trust 2007, 2009, All Rights Reserved
22

3+
from django.conf import settings
34
from django.conf.urls import patterns, include
45
from django.contrib import admin
56
from django.views.generic import TemplateView
7+
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
68

79
from ietf.liaisons.sitemaps import LiaisonMap
810
from ietf.ipr.sitemaps import IPRMap
911
from ietf import api
1012

11-
from django.conf import settings
12-
1313
admin.autodiscover()
1414
api.autodiscover()
1515

@@ -72,13 +72,24 @@
7272
(r'^api/v1/', include(a.urls)),
7373
)
7474

75-
# This is needed to serve files which are not handled by collectstatic:
75+
# This is needed to serve files during testing
7676
if settings.SERVER_MODE in ('development', 'test'):
77-
urlpatterns += patterns('',
78-
(r'^(?P<path>(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
79-
(r'^(?P<path>admin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
80-
(r'^(?P<path>secretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
81-
(r'^(?P<path>robots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}),
82-
(r'^_test500/$', lambda x: None),
83-
(r'^environment/$', 'ietf.help.views.environment'),
84-
)
77+
urlpatterns += ( staticfiles_urlpatterns()
78+
+ patterns('',
79+
(r'^_test500/$', lambda x: None),
80+
(r'^environment/$', 'ietf.help.views.environment'),
81+
## maybe preserve some static legacy URLs ?
82+
(r'^(?P<path>(?:images|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_ROOT+'ietf/'}),
83+
)
84+
)
85+
86+
# This is needed to serve files which are not handled by collectstatic :
87+
# if settings.SERVER_MODE in ('development', 'test'):
88+
# urlpatterns += patterns('',
89+
# (r'^(?P<path>(?:images|css|js|test|static)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
90+
# (r'^(?P<path>admin/(?:img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
91+
# (r'^(?P<path>secretariat/(img|css|js)/.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL}),
92+
# (r'^(?P<path>robots\.txt)$', 'django.views.static.serve', {'document_root': settings.STATIC_LOCAL+"dev/"}),
93+
# (r'^_test500/$', lambda x: None),
94+
# (r'^environment/$', 'ietf.help.views.environment'),
95+
# )

0 commit comments

Comments
 (0)