urls.py 2.5 KB

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