SoFunction
Updated on 2025-04-14

Simple code examples of Vue3 front-end and Python (Django) back-end interface

Writing views and APIs
  • existmyapp/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)
  • existmyapp/Configure URL:
from  import path
from. import views

urlpatterns = [
    path('api/data/', views.get_data, name='get_data'),
]
  • existmyproject/IncludedmyappURL configuration:
from  import admin
from  import path, include

urlpatterns = [
    path('admin/', ),
    path('', include('')),
]