Changes from server.
[cas.git] / src / cas / urls.py
index 4a285fd..2d44e70 100644 (file)
@@ -1,25 +1,29 @@
 # -*- coding: utf-8 -*-
-from django.conf.urls.defaults import *
-from django.views.generic.simple import redirect_to
+from django.urls import path, include
+from django.views.generic import RedirectView
 from django.contrib import admin
 from django.conf import settings
 
 admin.autodiscover()
 
-urlpatterns = patterns('',
-    url(r'^$', redirect_to, {'url': '/accounts/'}),
+urlpatterns = [
+    path('', RedirectView.as_view(url='/accounts/', permanent=False)),
 
     # django-cas-provider
-    url(r'^cas/', include('cas_provider.urls')),
+    path('cas/', include('cas_provider.urls')),
 
     # Admin panel
-    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
-    url(r'^admin/', include(admin.site.urls)),
+    path('admin/doc/', include('django.contrib.admindocs.urls')),
+    path('admin/', admin.site.urls),
 
-    url(r'^accounts/', include('accounts.urls')),
-
-    url(r'^%s(?P<path>.+)$' % settings.MEDIA_URL[1:], 'django.views.static.serve',
-        {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
-)
+    path('accounts/', include('accounts.urls')),
+]
 
 
+if settings.DEBUG:
+    from django.views.static import serve
+    urlpatterns += [
+        path('media/<path>', serve, {
+            'document_root': settings.MEDIA_ROOT,
+        }),
+   ]