2
0

urls.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import debug_toolbar
  2. from django.conf import settings
  3. from django.contrib import admin
  4. from django.urls import include, 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 bakerydemo.search import views as search_views
  10. from .api import api_router
  11. urlpatterns = [
  12. path("django-admin/", admin.site.urls),
  13. path("admin/", include(wagtailadmin_urls)),
  14. path("documents/", include(wagtaildocs_urls)),
  15. path("search/", search_views.search, name="search"),
  16. path("sitemap.xml", sitemap),
  17. path("api/v2/", api_router.urls),
  18. path("__debug__/", include(debug_toolbar.urls)),
  19. ]
  20. if settings.DEBUG:
  21. from django.conf.urls.static import static
  22. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  23. from django.views.generic import TemplateView
  24. from django.views.generic.base import RedirectView
  25. # Serve static and media files from development server
  26. urlpatterns += staticfiles_urlpatterns()
  27. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  28. urlpatterns += [
  29. path(
  30. "favicon.ico",
  31. RedirectView.as_view(url=settings.STATIC_URL + "img/bread-favicon.ico"),
  32. )
  33. ]
  34. # Add views for testing 404 and 500 templates
  35. urlpatterns += [
  36. path("test404/", TemplateView.as_view(template_name="404.html")),
  37. path("test500/", TemplateView.as_view(template_name="500.html")),
  38. ]
  39. urlpatterns += [
  40. path("", include(wagtail_urls)),
  41. ]