url(r'^admin/', include(admin.site.urls)), ) 修改之后重启服务器,访问localhost:8000/polls/就可以看到hello world的界面. 刚才添加一个view的流程就是先在poll/views.py添加新的view,然后在polls/urls.py创建一个新的URLconf,最后在根的mysite/urls.py中把它include进去 现在再添加多几个views 1 2 3 ...
AI代码解释 from django.conf.urlsimporturl,include from rest_frameworkimportrouters from tutorial.quickstartimportviews router=routers.DefaultRouter()router.register(r'users',views.UserViewSet)router.register(r'groups',views.GroupViewSet)# 使用自动URL路由连接我们的API。 # 另外,我们还包括支持浏览器浏览API...
按从上到下的顺序匹配2. 采用 include 函数可以包含其他 app 的 urls,namespace 参数定义后可以在模板...
好了,现在我们来连接 API URL。进入 tutorial/urls.py... from django.urls import include, path from rest_framework import routers from quickstart import views # 创建子路由 router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) router.register(r'groups', views.GroupViewSet)...
path('api-auth/', include('rest_framework.urls')) ] 快速使用 我们将创建一个简单的 API 来允许管理员用户查看和编辑系统中的用户和组。 项目设置 创建一个名为 的新 Django 项目tutorial,然后启动一个名为 的新应用程序quickstart。 # 创建tutorial并切换到tutorial目录mkdir tutorial ...
Installed Django already? Good. Nowtry this tutorial, which walks you through creating a basic poll application. It’s got two parts: A public site that lets people view polls and vote in them. An administrative interface that lets you add, change and delete polls. ...
URLs 好,现在我们来装配API的URLs。进入tutorial/urls.py 代码语言:javascript 代码运行次数:0 运行 AI代码解释 from django.conf.urlsimporturl,include from rest_frameworkimportrouters from tutorial.quickstartimportviews router=routers.DefaultRouter()router.register(r'users',views.UserViewSet)router.register(r...
) while others examine the overall operation of the software (does a sequence of user inputs on the site produce the desired result?). That’s no different from the kind of testing you did earlier inTutorial 2, using theshellto examine the behavior of a method, or running the application...
Learning by Doing In this tutorial you get a step by step guide on how to install and create a Django project. You will learn how to create a project where you can add, read, update or delete data. You will learn how to make HTML Templates and use Django Template Tags to insert data...
from django.contrib import admin from django.urls import include, path urlpatterns = [ path("admin/", admin.site.urls), ] Create an admin user: / $ python manage.py createsuperuser Next, start up the Django development server: / $ python manage.py runserve...