2015-04-22 03:54:00 +08:00
|
|
|
from functools import partial
|
2007-09-17 22:48:33 +08:00
|
|
|
from os import path
|
|
|
|
|
2015-01-28 20:35:27 +08:00
|
|
|
from django.conf.urls import include, url
|
2015-03-12 16:32:29 +08:00
|
|
|
from django.conf.urls.i18n import i18n_patterns
|
2017-01-27 03:58:33 +08:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2014-08-12 22:54:42 +08:00
|
|
|
from django.views import defaults, i18n, static
|
2007-09-19 21:26:56 +08:00
|
|
|
|
2011-10-14 05:34:56 +08:00
|
|
|
from . import views
|
2007-09-17 22:48:33 +08:00
|
|
|
|
2017-01-20 21:01:02 +08:00
|
|
|
base_dir = path.dirname(path.abspath(__file__))
|
2007-09-17 22:48:33 +08:00
|
|
|
media_dir = path.join(base_dir, 'media')
|
|
|
|
locale_dir = path.join(base_dir, 'locale')
|
|
|
|
|
2014-04-02 08:46:34 +08:00
|
|
|
urlpatterns = [
|
|
|
|
url(r'^$', views.index_page),
|
2008-07-19 03:45:00 +08:00
|
|
|
|
2007-09-19 21:26:56 +08:00
|
|
|
# Default views
|
2017-02-03 09:43:21 +08:00
|
|
|
url(r'^nonexistent_url/', partial(defaults.page_not_found, exception=None)),
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'^server_error/', defaults.server_error),
|
2008-07-19 03:45:00 +08:00
|
|
|
|
2011-04-02 21:27:40 +08:00
|
|
|
# a view that raises an exception for the debug view
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'raises/$', views.raises),
|
2013-08-04 17:01:01 +08:00
|
|
|
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'raises400/$', views.raises400),
|
|
|
|
url(r'raises403/$', views.raises403),
|
|
|
|
url(r'raises404/$', views.raises404),
|
|
|
|
url(r'raises500/$', views.raises500),
|
2011-04-02 21:27:40 +08:00
|
|
|
|
2014-06-16 15:39:18 +08:00
|
|
|
url(r'technical404/$', views.technical404, name="my404"),
|
|
|
|
url(r'classbased404/$', views.Http404View.as_view()),
|
|
|
|
|
2007-09-19 21:26:56 +08:00
|
|
|
# i18n views
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'^i18n/', include('django.conf.urls.i18n')),
|
2016-03-08 04:52:08 +08:00
|
|
|
url(r'^jsi18n/$', i18n.JavaScriptCatalog.as_view(packages=['view_tests'])),
|
|
|
|
url(r'^jsi18n/app1/$', i18n.JavaScriptCatalog.as_view(packages=['view_tests.app1'])),
|
|
|
|
url(r'^jsi18n/app2/$', i18n.JavaScriptCatalog.as_view(packages=['view_tests.app2'])),
|
|
|
|
url(r'^jsi18n/app5/$', i18n.JavaScriptCatalog.as_view(packages=['view_tests.app5'])),
|
|
|
|
url(r'^jsi18n_english_translation/$', i18n.JavaScriptCatalog.as_view(packages=['view_tests.app0'])),
|
|
|
|
url(r'^jsi18n_multi_packages1/$',
|
|
|
|
i18n.JavaScriptCatalog.as_view(packages=['view_tests.app1', 'view_tests.app2'])),
|
|
|
|
url(r'^jsi18n_multi_packages2/$',
|
|
|
|
i18n.JavaScriptCatalog.as_view(packages=['view_tests.app3', 'view_tests.app4'])),
|
|
|
|
url(r'^jsi18n_admin/$',
|
|
|
|
i18n.JavaScriptCatalog.as_view(packages=['django.contrib.admin', 'view_tests'])),
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'^jsi18n_template/$', views.jsi18n),
|
2014-02-23 22:10:31 +08:00
|
|
|
url(r'^jsi18n_multi_catalogs/$', views.jsi18n_multi_catalogs),
|
2016-03-08 04:52:08 +08:00
|
|
|
url(r'^jsoni18n/$', i18n.JSONCatalog.as_view(packages=['view_tests'])),
|
2008-07-19 03:45:00 +08:00
|
|
|
|
2007-09-19 21:26:56 +08:00
|
|
|
# Static views
|
2016-08-10 23:27:03 +08:00
|
|
|
url(r'^site_media/(?P<path>.*)$', static.serve, {'document_root': media_dir, 'show_indexes': True}),
|
2014-04-02 08:46:34 +08:00
|
|
|
]
|
|
|
|
|
2015-03-12 16:32:29 +08:00
|
|
|
urlpatterns += i18n_patterns(
|
|
|
|
url(_(r'^translated/$'), views.index_page, name='i18n_prefixed'),
|
|
|
|
)
|
|
|
|
|
2014-04-02 08:46:34 +08:00
|
|
|
urlpatterns += [
|
2017-02-04 08:38:33 +08:00
|
|
|
url(r'template_exception/$', views.template_exception, name='template_exception'),
|
2015-09-12 07:33:12 +08:00
|
|
|
url(
|
|
|
|
r'^raises_template_does_not_exist/(?P<path>.+)$',
|
|
|
|
views.raises_template_does_not_exist,
|
|
|
|
name='raises_template_does_not_exist'
|
|
|
|
),
|
2014-04-02 08:46:34 +08:00
|
|
|
url(r'^render_no_template/$', views.render_no_template, name='render_no_template'),
|
2016-04-06 22:11:23 +08:00
|
|
|
url(r'^test-setlang/(?P<parameter>[^/]+)/$', views.with_parameter, name='with_parameter'),
|
2014-04-02 08:46:34 +08:00
|
|
|
]
|