urls.py 1.09 KB
Newer Older
1 2 3
#!/usr/bin/env python
# -*- encoding: utf-8 -*-

4 5 6 7 8 9 10 11
""" Module urls principal.
    
    Sert essentiellement à rediriger vers :py:mod:`note.urls`.
    
    Rajoute aussi la config pour servir les fichiers statiques quand on
    est en mode DEBUG.
"""

Charlie Jacomme's avatar
Charlie Jacomme committed
12 13
from django.conf.urls import include, url
from django.conf.urls.static import static
14
from note import settings
15 16 17 18

if settings.DEBUG:
    # On n'utilise pas ça en prod
    from django.contrib.staticfiles.urls import staticfiles_urlpatterns
19

20 21 22
#: Handlers custom pour les erreurs
handler400 = "note.views.bad_request"
handler403 = "note.views.permission_denied"
Vincent Le gallic's avatar
Vincent Le gallic committed
23
handler404 = "note.views.page_not_found"
24 25
handler500 = "note.views.server_error"

Vincent Le gallic's avatar
Vincent Le gallic committed
26

27 28
from django.contrib import admin
admin.autodiscover()
Charlie Jacomme's avatar
Charlie Jacomme committed
29 30
import note.urls
urlpatterns = [
31
    url(r'^' + settings.NOTE_ROOT_URL.strip('/'), include('note.urls')),
32
    url(r'', include('note.urls')),
Vincent Le gallic's avatar
Vincent Le gallic committed
33
    url(r'^admin/', include(admin.site.urls)),
Charlie Jacomme's avatar
Charlie Jacomme committed
34
]
35

36 37 38
if settings.DEBUG:
    # On n'utilise pas ça en prod
    urlpatterns += staticfiles_urlpatterns()
Charlie Jacomme's avatar
Charlie Jacomme committed
39
    urlpatterns +=  static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)