urls.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. """{{ project_name }} URL Configuration
  2. The `urlpatterns` list routes URLs to views. For more information please see:
  3. https://docs.djangoproject.com/en/1.10/topics/http/urls/
  4. Examples:
  5. Function views
  6. 1. Add an import: from my_app import views
  7. 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
  8. Class-based views
  9. 1. Add an import: from other_app.views import Home
  10. 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
  11. Including another URLconf
  12. 1. Import the include() function: from django.conf.urls import url, include
  13. 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
  14. """
  15. from django.conf import settings
  16. from django.conf.urls import include, url
  17. from django.conf.urls.static import static
  18. from django.contrib import admin
  19. from django.views.generic import TemplateView
  20. from misago.core.views import javascript_catalog
  21. from misago.users.forms.auth import AdminAuthenticationForm
  22. admin.autodiscover()
  23. admin.site.login_form = AdminAuthenticationForm
  24. urlpatterns = [
  25. url(r'^', include('misago.urls', namespace='misago')),
  26. # Javascript translations
  27. url(r'^django-i18n.js$', javascript_catalog, name='django-i18n'),
  28. # Uncomment next line if you plan to use Django admin for 3rd party apps
  29. #url(r'^django-admin/', include(admin.site.urls)),
  30. ]
  31. # If debug mode is enabled, include debug toolbar
  32. if settings.DEBUG:
  33. import debug_toolbar
  34. urlpatterns += [
  35. url(r'^__debug__/', include(debug_toolbar.urls)),
  36. ]
  37. # Use static file server for static and media files (debug only)
  38. urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
  39. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  40. # Error Handlers
  41. # Misago needs those handlers to deal with errors raised by it's middlewares
  42. # If you replace those handlers with custom ones, make sure you decorate them
  43. # with shared_403_exception_handler or shared_404_exception_handler
  44. # decorators that are defined in misago.views.errorpages module!
  45. handler403 = 'misago.core.errorpages.permission_denied'
  46. handler404 = 'misago.core.errorpages.page_not_found'