urls specified in yourapp/urls.py
to link with views
https://docs.djangoproject.com/en/4.0/ref/urlresolvers/
urlpatterns = [
# https://docs.djangoproject.com/en/4.0/ref/urlresolvers/
# path('archive/', views.archive, name='news-archive')
# reverse('news-archive')
path('create/', views.CreateUserView.as_view(), name='create'),
path('token/', views.CreateTokenView.as_view(), name='token'),
path('me/', views.ManageUserView.as_view(), name='me'),
]
Urls can be assed by code through reverse
https://docs.djangoproject.com/en/4.0/ref/urlresolvers/
# path('archive/', views.archive, name='news-archive')
# reverse('news-archive')
# reverse('{{app_name}}:{{path_name}})
CREATE_USER_URL = reverse('user:create')
URL also need to be instaniated in project urls.py
urlpatterns = [
path('api/user/', include('myapp.urls')),
]
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# django resetframework https://www.django-rest-framework.org/tutorial/quickstart/
'rest_framework',
# django autho token https://www.django-rest-framework.org/api-guide/authentication/
'rest_framework.authtoken',
# core app folder created when running python manage.py startapp core
'myapp'
]
No comments:
Post a Comment