#urls.py from django.contrib import admin from django.urls import path, re_path from app01 import views urlpatterns = [ path(‘admin/‘, admin.site.urls), re_path(r‘^student/‘, views.StudentView.as_view()), ]
#views.py from django.shortcuts import render, HttpResponse from django.views import View from app01 import models class StudentView(View): def get(self, request): models.UserInfo.objects.create(name=‘yyy‘, password=‘123‘) return HttpResponse(‘hello word‘)
原文:https://www.cnblogs.com/yangyangming/p/11516308.html