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