from django.conf import settings from django.urls import path, re_path from django.views.generic import RedirectView from . import views, views_debug urlpatterns = [ path("", views.index, name="homepage"), path("search/", views.redirect_search), path("/", views.language), re_path( r"^[a-z-]+/[\w.-]+/internals/team/$", RedirectView.as_view( url="https://www.djangoproject.com/foundation/teams/", permanent=True, ), ), re_path("^(?P[a-z-]+)/(?Pstable)/(?P.*)$", views.stable), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/$", views.document, {"url": ""}, name="document-index", ), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/_images/(?P.*)$", views_debug.sphinx_static, {"subpath": "_images"}, ), re_path("^(.*)/index/$", views.redirect_index), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/search/$", views.search_results, name="document-search", ), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/search/description/$", views.search_description, name="document-search-description", ), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/search/suggestions/$", views.search_suggestions, name="document-search-suggestions", ), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/(?P[\w./-]*)/$", views.document, name="document-detail", ), ] if settings.DEBUG: # Patterns for sphinx (in production they are served by nginx directly) # They need to be inserted at the beginning to take precedence over document-detail urlpatterns = [ re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/_objects/$", views_debug.objects_inventory, ), re_path( r"^(?P[a-z-]+)/(?P[\w.-]+)/(?P_downloads|_source)/(?P.*)$", # noqa: E501 views_debug.sphinx_static, ), re_path(r"^pots/(?P\w+\.pot)$", views_debug.pot_file), *urlpatterns, ]