urls.py 2.4 KB

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