urls.py 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. """devproject 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.static import static
  17. from django.contrib import admin
  18. from django.urls import include, path
  19. from django.utils import timezone
  20. from django.views.decorators.cache import cache_page
  21. from django.views.decorators.http import last_modified
  22. from django.views.i18n import JavaScriptCatalog
  23. from misago.users.forms.auth import AdminAuthenticationForm
  24. admin.autodiscover()
  25. admin.site.login_form = AdminAuthenticationForm
  26. urlpatterns = [
  27. path("", include("misago.urls", namespace="misago")),
  28. # Javascript translations
  29. path(
  30. "django-i18n.js",
  31. last_modified(lambda req, **kw: timezone.now())(
  32. cache_page(86400 * 2, key_prefix="misagojsi18n")(
  33. JavaScriptCatalog.as_view(packages=["misago"])
  34. )
  35. ),
  36. name="django-i18n",
  37. ),
  38. # Uncomment next line if you plan to use Django admin for 3rd party apps
  39. path("django-admin/", admin.site.urls),
  40. ]
  41. # If debug mode is enabled, include debug toolbar
  42. if settings.DEBUG:
  43. import debug_toolbar
  44. urlpatterns += [path("__debug__/", include(debug_toolbar.urls))]
  45. # Use static file server for static and media files (debug only)
  46. urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
  47. urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  48. # Error Handlers
  49. # Misago needs those handlers to deal with errors raised by it's middlewares
  50. # If you replace those handlers with custom ones, make sure you decorate them
  51. # with shared_403_exception_handler or shared_404_exception_handler
  52. # decorators that are defined in misago.views.errorpages module!
  53. handler403 = "misago.core.errorpages.permission_denied"
  54. handler404 = "misago.core.errorpages.page_not_found"