2
0

urls.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import debug_toolbar
  2. from django.conf import settings
  3. from django.contrib import admin
  4. from django.urls import include, path, re_path
  5. from wagtail import urls as wagtail_urls
  6. from wagtail.admin import urls as wagtailadmin_urls
  7. from wagtail.contrib.sitemaps.views import sitemap
  8. from wagtail.documents import urls as wagtaildocs_urls
  9. from wagtail.images.views.serve import ServeView
  10. from bakerydemo.search import views as search_views
  11. from .api import api_router
  12. urlpatterns = [
  13. path("django-admin/", admin.site.urls),
  14. path("admin/", include(wagtailadmin_urls)),
  15. path("documents/", include(wagtaildocs_urls)),
  16. re_path(
  17. r"^images/([^/]*)/(\d*)/([^/]*)/[^/]*$",
  18. ServeView.as_view(),
  19. name="wagtailimages_serve",
  20. ),
  21. path("search/", search_views.search, name="search"),
  22. path("sitemap.xml", sitemap),
  23. path("api/v2/", api_router.urls),
  24. path("__debug__/", include(debug_toolbar.urls)),
  25. ]
  26. if settings.DEBUG:
  27. from django.conf.urls.static import static
  28. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  29. from django.views.generic import TemplateView
  30. from django.views.generic.base import RedirectView
  31. # Serve static and media files from development server
  32. urlpatterns += staticfiles_urlpatterns()
  33. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  34. urlpatterns += [
  35. path(
  36. "favicon.ico",
  37. RedirectView.as_view(url=settings.STATIC_URL + "img/bread-favicon.ico"),
  38. )
  39. ]
  40. # Add views for testing 404 and 500 templates
  41. urlpatterns += [
  42. path("test404/", TemplateView.as_view(template_name="404.html")),
  43. path("test500/", TemplateView.as_view(template_name="500.html")),
  44. ]
  45. urlpatterns += [
  46. path("", include(wagtail_urls)),
  47. ]