password
查看人数
type
status
date
slug
summary
category
icon
tags
作者
状态
😀
Django 项目搭建
 
安装 pip install Django

创建项目

创建项目 django-admin startproject HelloWorld
进入项目 cd HelloWorld
创建app python manage.py startapp accounts
进入accounts,添加urls.py
为项目添加路由
notion image
mode操作后迁移 python manage.py makemigrations
notion image
创建基础表(迁移 ) python manage.py migrate
notion image
添加管理员 python manage.py createsuperuser
notion image
运行 python manage.py runserver
notion image

MySQL配置

进入目录first/first/settings.py中,找到:
notion image
修改为:
在项目中的init.py,在里面输入以下内容并保存:

弹窗提示

前端代码,放在body前
后端代码

ORM查询

notion image

ORM 写法

SQL as 重命名,orm实现

查询结果
notion image
注意:
跨表重命名id字段时,不能重命名为id,为id时会与原来表的id重复不能查询出数据

view

django添加响应状态码
 
 
 
 
💡
有关使用上的问题,欢迎您在底部评论区留言,一起交流~
citcon踩坑JUnit 5 执行顺序和参数化运行
Loading...