urls.py 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. from __future__ import unicode_literals
  2. from django.conf.urls import include, url
  3. from django.conf.urls.i18n import i18n_patterns
  4. from django.contrib import admin
  5. from django.views.i18n import set_language
  6. from mezzanine.core.views import direct_to_template
  7. from mezzanine.conf import settings
  8. admin.autodiscover()
  9. # Add the urlpatterns for any custom Django applications here.
  10. # You can also change the ``home`` view to add your own functionality
  11. # to the project's homepage.
  12. urlpatterns = i18n_patterns(
  13. # Change the admin prefix here to use an alternate URL for the
  14. # admin interface, which would be marginally more secure.
  15. url("^admin/", include(admin.site.urls)),
  16. )
  17. if settings.USE_MODELTRANSLATION:
  18. urlpatterns += [
  19. url('^i18n/$', set_language, name='set_language'),
  20. ]
  21. urlpatterns += [
  22. # We don't want to presume how your homepage works, so here are a
  23. # few patterns you can use to set it up.
  24. # HOMEPAGE AS STATIC TEMPLATE
  25. # ---------------------------
  26. # This pattern simply loads the index.html template. It isn't
  27. # commented out like the others, so it's the default. You only need
  28. # one homepage pattern, so if you use a different one, comment this
  29. # one out.
  30. url("^$", direct_to_template, {"template": "index.html"}, name="home"),
  31. # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE
  32. # ---------------------------------------------
  33. # This pattern gives us a normal ``Page`` object, so that your
  34. # homepage can be managed via the page tree in the admin. If you
  35. # use this pattern, you'll need to create a page in the page tree,
  36. # and specify its URL (in the Meta Data section) as "/", which
  37. # is the value used below in the ``{"slug": "/"}`` part.
  38. # Also note that the normal rule of adding a custom
  39. # template per page with the template name using the page's slug
  40. # doesn't apply here, since we can't have a template called
  41. # "/.html" - so for this case, the template "pages/index.html"
  42. # should be used if you want to customize the homepage's template.
  43. # NOTE: Don't forget to import the view function too!
  44. # url("^$", mezzanine.pages.views.page, {"slug": "/"}, name="home"),
  45. # HOMEPAGE FOR A BLOG-ONLY SITE
  46. # -----------------------------
  47. # This pattern points the homepage to the blog post listing page,
  48. # and is useful for sites that are primarily blogs. If you use this
  49. # pattern, you'll also need to set BLOG_SLUG = "" in your
  50. # ``settings.py`` module, and delete the blog page object from the
  51. # page tree in the admin if it was installed.
  52. # NOTE: Don't forget to import the view function too!
  53. # url("^$", mezzanine.blog.views.blog_post_list, name="home"),
  54. # MEZZANINE'S URLS
  55. # ----------------
  56. # ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW.
  57. # ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN
  58. # FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls``
  59. # WILL NEVER BE MATCHED!
  60. # If you'd like more granular control over the patterns in
  61. # ``mezzanine.urls``, go right ahead and take the parts you want
  62. # from it, and use them directly below instead of using
  63. # ``mezzanine.urls``.
  64. url("^", include("mezzanine.urls")),
  65. # MOUNTING MEZZANINE UNDER A PREFIX
  66. # ---------------------------------
  67. # You can also mount all of Mezzanine's urlpatterns under a
  68. # URL prefix if desired. When doing this, you need to define the
  69. # ``SITE_PREFIX`` setting, which will contain the prefix. Eg:
  70. # SITE_PREFIX = "my/site/prefix"
  71. # For convenience, and to avoid repeating the prefix, use the
  72. # commented out pattern below (commenting out the one above of course)
  73. # which will make use of the ``SITE_PREFIX`` setting. Make sure to
  74. # add the import ``from django.conf import settings`` to the top
  75. # of this file as well.
  76. # Note that for any of the various homepage patterns above, you'll
  77. # need to use the ``SITE_PREFIX`` setting as well.
  78. # ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls"))
  79. ]
  80. # Adds ``STATIC_URL`` to the context of error pages, so that error
  81. # pages can use JS, CSS and images.
  82. handler404 = "mezzanine.core.views.page_not_found"
  83. handler500 = "mezzanine.core.views.server_error"