Reputation: 1054
core/settings.py
INSTALLED_APPS = [
...
'api.apps.ApiConfig',
...
]
core/urls.py (app URL configuration)
urlpatterns = [
path('api', include("api.urls")),
]
api/urls.py
urlpatterns = [
path("", views.index, name="API Overview"),
path("establishment/<str:username>", views.get_id_establishment_auth, name="task-establishment"),
]
api/views.py
@api_view(['GET'])
def get_id_establishment_auth(request, username):
print(username)
return HttpResponse('Success');
The above code will result a 404 page Page not found if i type http://127.0.0.1:8000/api/establishment/mark when mark is a path converter
i cant get what is the problem but looks like the path converter is not working (str:username).
Upvotes: 2
Views: 572
Reputation: 1721
you are missing a /
in api for path('api', include("api.urls"))
so should be path('api/', include("api.urls"))
Upvotes: 2