# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView

#from rest_framework.routers import DefaultRouter
from rest_framework.urlpatterns import format_suffix_patterns

from commonrepo.api.routers import DefaultRouter
from commonrepo.snippets_api.views import SnippetViewSet
from commonrepo.users_api.views import UserViewSet
from commonrepo.elos_api.views import ELOViewSet

router_api = DefaultRouter()
router_api.register(r'api/snippets', SnippetViewSet)
router_api.register(r'api/users', UserViewSet)
router_api.register(r'api/elos', ELOViewSet)


urlpatterns = [
    url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name="home"),
    url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name="about"),

    # Django Admin
    url(r'^admin/', include(admin.site.urls)),

    # User management
    url(r'^users/', include("commonrepo.users.urls", namespace="users")),
    url(r'^accounts/', include('allauth.urls')),

    # Your stuff: custom urls includes go here
    url(r'^elos/', include("commonrepo.elos.urls", namespace="elos")),

    # API endpoints
    url(r'^', include(router_api.urls)),
    url(r'^api/auth', include('rest_framework.urls', namespace='rest_framework'))


] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        url(r'^400/$', 'django.views.defaults.bad_request'),
        url(r'^403/$', 'django.views.defaults.permission_denied'),
        url(r'^404/$', 'django.views.defaults.page_not_found'),
        url(r'^500/$', 'django.views.defaults.server_error'),
    ]

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
from django.conf.urls import include, url
from django.conf.urls.static import static
from django.contrib import admin
from django.views.generic import TemplateView

#from rest_framework.routers import DefaultRouter
from rest_framework.urlpatterns import format_suffix_patterns

from commonrepo.api.routers import DefaultRouter
from commonrepo.snippets_api.views import SnippetViewSet
from commonrepo.users_api.views import UserViewSet
from commonrepo.elos_api.views import ELOViewSet

router_api = DefaultRouter()
router_api.register(r'api/snippets', SnippetViewSet)
router_api.register(r'api/users', UserViewSet)
router_api.register(r'api/elos', ELOViewSet)


urlpatterns = [
    url(r'^$', TemplateView.as_view(template_name='pages/home.html'), name="home"),
    url(r'^about/$', TemplateView.as_view(template_name='pages/about.html'), name="about"),

    # Django Admin
    url(r'^admin/', include(admin.site.urls)),

    # User management
    url(r'^users/', include("commonrepo.users.urls", namespace="users")),
    url(r'^accounts/', include('allauth.urls')),

    # Your stuff: custom urls includes go here
    url(r'^elos/', include("commonrepo.elos.urls", namespace="elos")),

    # API endpoints
    url(r'^', include(router_api.urls)),
    url(r'^api/auth/v0/', include('rest_framework.urls', namespace='rest_framework'))


] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
    # This allows the error pages to be debugged during development, just visit
    # these url in browser to see how these error pages look like.
    urlpatterns += [
        url(r'^400/$', 'django.views.defaults.bad_request'),
        url(r'^403/$', 'django.views.defaults.permission_denied'),
        url(r'^404/$', 'django.views.defaults.page_not_found'),
        url(r'^500/$', 'django.views.defaults.server_error'),
    ]

修改 url 設定，將 REST Framework 提供的登入登出 method 定義為 API Auth v0