|
@@ -13,9 +13,22 @@ Including another URLconf
|
|
|
1. Import the include() function: from django.urls import include, path
|
|
1. Import the include() function: from django.urls import include, path
|
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
|
|
"""
|
|
"""
|
|
|
|
|
+from django.conf.urls import url
|
|
|
from django.contrib import admin
|
|
from django.contrib import admin
|
|
|
-from django.urls import path
|
|
|
|
|
|
|
+from django.urls import path, include
|
|
|
|
|
+from rest_framework import routers
|
|
|
|
|
+
|
|
|
|
|
+from apps.user import views as user_views
|
|
|
|
|
+from rest_framework.authtoken import views as authtoken_views
|
|
|
|
|
+
|
|
|
|
|
+router = routers.DefaultRouter()
|
|
|
|
|
+router.register(r'users', user_views.UserViewSet)
|
|
|
|
|
|
|
|
urlpatterns = [
|
|
urlpatterns = [
|
|
|
|
|
+ path('', include(router.urls)),
|
|
|
|
|
+ path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
|
|
|
path('admin/', admin.site.urls),
|
|
path('admin/', admin.site.urls),
|
|
|
|
|
+ url(r'^api-token-auth/', authtoken_views.obtain_auth_token),
|
|
|
|
|
+
|
|
|
|
|
+ url('^who-am-i/', user_views.CurrentUserView.as_view(), name='who-am-i'),
|
|
|
]
|
|
]
|