urls.py 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. """healthdiarybackend URL Configuration
  2. The `urlpatterns` list routes URLs to views. For more information please see:
  3. https://docs.djangoproject.com/en/3.0/topics/http/urls/
  4. Examples:
  5. Function views
  6. 1. Add an import: from my_app import views
  7. 2. Add a URL to urlpatterns: path('', views.home, name='home')
  8. Class-based views
  9. 1. Add an import: from other_app.views import Home
  10. 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
  11. Including another URLconf
  12. 1. Import the include() function: from django.urls import include, path
  13. 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
  14. """
  15. from django.conf.urls import url
  16. from django.contrib import admin
  17. from django.urls import path, include
  18. from rest_framework import routers
  19. from apps.patient.models import Patient
  20. from apps.user import views as user_views
  21. from apps.patient import views as patient_views
  22. from apps.indicatortype import views as indicatortype_views
  23. from apps.user.serializers import CustomAuthToken
  24. router = routers.DefaultRouter()
  25. router.register(r'users', user_views.UserViewSet)
  26. router.register(r'patients', patient_views.PatientViewSet, Patient)
  27. router.register(r'indicatortype', indicatortype_views.IndicatorTypeViewSet)
  28. urlpatterns = [
  29. path('', include(router.urls)),
  30. path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
  31. path('admin/', admin.site.urls),
  32. # url(r'^api-token-auth/', authtoken_views.obtain_auth_token),
  33. url(r'^login/', CustomAuthToken.as_view()),
  34. url('^register/', user_views.CreateUserView.as_view(), name='register-user'),
  35. url('^who-am-i/', user_views.CurrentUserView.as_view(), name='who-am-i'),
  36. url('^add-user-to-patient/', patient_views.AddUserForPatient.as_view(), name='add-user-to-patient'),
  37. ]