You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

urls.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. import django
  2. from django.apps import apps
  3. from django.conf import settings
  4. from django.conf.urls import include, url
  5. from django.conf.urls.i18n import i18n_patterns
  6. from django.conf.urls.static import static
  7. from django.contrib import admin
  8. from django.contrib.sitemaps import views
  9. from oscar.views import handler403, handler404, handler500
  10. from apps.sitemaps import base_sitemaps
  11. admin.autodiscover()
  12. urlpatterns = [
  13. # Include admin as convenience. It's unsupported and only included
  14. # for developers.
  15. url(r'^admin/', admin.site.urls),
  16. # i18n URLS need to live outside of i18n_patterns scope of Oscar
  17. url(r'^i18n/', include(django.conf.urls.i18n)),
  18. # include a basic sitemap
  19. url(r'^sitemap\.xml$', views.index,
  20. {'sitemaps': base_sitemaps}),
  21. url(r'^sitemap-(?P<section>.+)\.xml$', views.sitemap,
  22. {'sitemaps': base_sitemaps},
  23. name='django.contrib.sitemaps.views.sitemap')
  24. ]
  25. # Prefix Oscar URLs with language codes
  26. urlpatterns += i18n_patterns(
  27. url(r'^', include(apps.get_app_config('oscar').urls[0])),
  28. )
  29. if settings.DEBUG:
  30. import debug_toolbar
  31. # Server statics and uploaded media
  32. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  33. # Allow error pages to be tested
  34. urlpatterns += [
  35. url(r'^403$', handler403, {'exception': Exception()}),
  36. url(r'^404$', handler404, {'exception': Exception()}),
  37. url(r'^500$', handler500),
  38. url(r'^__debug__/', include(debug_toolbar.urls)),
  39. ]