Writing views and APIs:
- exist
myapp/
Write a simple view function in :
from import JsonResponse def get_data(request): data = {'message': 'This is data from the Django backend'} return JsonResponse(data)
- exist
myapp/
Configure URL:
from import path from. import views urlpatterns = [ path('api/data/', views.get_data, name='get_data'), ]
- exist
myproject/
Includedmyapp
URL configuration:
from import admin from import path, include urlpatterns = [ path('admin/', ), path('', include('')), ]