urls.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. from django.conf.urls import include, url
  2. from django.conf import settings
  3. from django.contrib import admin
  4. from wagtail.admin import urls as wagtailadmin_urls
  5. from wagtail.documents import urls as wagtaildocs_urls
  6. from wagtail.core import urls as wagtail_urls
  7. from bakerydemo.search import views as search_views
  8. urlpatterns = [
  9. url(r'^django-admin/', admin.site.urls),
  10. url(r'^admin/', include(wagtailadmin_urls)),
  11. url(r'^documents/', include(wagtaildocs_urls)),
  12. url(r'^search/$', search_views.search, name='search'),
  13. ]
  14. if settings.DEBUG:
  15. from django.conf.urls.static import static
  16. from django.contrib.staticfiles.urls import staticfiles_urlpatterns
  17. from django.views.generic import TemplateView
  18. from django.views.generic.base import RedirectView
  19. # Serve static and media files from development server
  20. urlpatterns += staticfiles_urlpatterns()
  21. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  22. urlpatterns += [
  23. url(
  24. r'^favicon\.ico$', RedirectView.as_view(
  25. url=settings.STATIC_URL + 'img/bread-favicon.ico'
  26. )
  27. )
  28. ]
  29. # Add views for testing 404 and 500 templates
  30. urlpatterns += [
  31. url(r'^test404/$', TemplateView.as_view(template_name='404.html')),
  32. url(r'^test500/$', TemplateView.as_view(template_name='500.html')),
  33. ]
  34. urlpatterns += [
  35. url(r'', include(wagtail_urls)),
  36. ]