上一页 1 2 3 4 5 6 7 ··· 13 下一页
摘要: django-orm更新数据 单个数据修改(更新单个数据) In [6]: b1=Book.objects.get(id=1) In [7]: b1.price Out[7]: Decimal('20.00') In [8]: b1.price=22 mysql> select * from boo 阅读全文
posted @ 2021-08-10 11:05 yescarf 阅读(1158) 评论(0) 推荐(0) 编辑
摘要: django-orm查询操作02 条件查询-方法 官网文档 包含某个和某个filter # filter 多个条件 表示select 字段1 from 表名 where 条件1 and 条件2 In [1]: from bookstore.models import Book In [2]: b1= 阅读全文
posted @ 2021-08-09 20:05 yescarf 阅读(59) 评论(0) 推荐(0) 编辑
摘要: django-orm查询操作 In [19]: from bookstore.models import Book In [20]: a1=Book.objects.all() In [21]: a1 Out[21]: <QuerySet [<Book: Book object (1)>, <Boo 阅读全文
posted @ 2021-08-09 19:32 yescarf 阅读(86) 评论(0) 推荐(0) 编辑
摘要: 方案1 python manage.py shell In [3]: b1=Book.objects.create(title='python',pub='清华大学出版社',price=20,mar ...: ket_price=25) In [4]: b1 Out[4]: <Book: Book 阅读全文
posted @ 2021-08-07 18:05 yescarf 阅读(44) 评论(0) 推荐(0) 编辑
摘要: 迁移时字段默认值 最好选择2显性显示数据修改情况,防止他人接手时存在黑匣子 数据库迁移文件混乱 执行迁移文件的记录会存在数据库中(表django_migrations) mysql> select * from django_migrations; + + + + + | id | app | na 阅读全文
posted @ 2021-08-07 17:49 yescarf 阅读(78) 评论(0) 推荐(0) 编辑
摘要: orm基础字段及选项 字段类型 from django.db import models # Create your models here. class Book(models.Model): title=models.CharField('书名',max_length=50,default='' 阅读全文
posted @ 2021-08-07 10:09 yescarf 阅读(63) 评论(0) 推荐(0) 编辑
摘要: django模型层 settings.py DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'mysite2', 'USER':'root', 'PASSWORD':'password', 'HOST' 阅读全文
posted @ 2021-08-06 09:43 yescarf 阅读(39) 评论(0) 推荐(0) 编辑
摘要: django应用配置、注册 django分布式路由 django应用下的模板 阅读全文
posted @ 2021-08-05 19:53 yescarf 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 配置静态文件 static_url 、 static_root 、 STATICFILES_DIR的区别 三者表内关系 简单陈述说明 static加载 views.py from django.http import HttpResponse from django.shortcuts import 阅读全文
posted @ 2021-08-05 09:49 yescarf 阅读(458) 评论(0) 推荐(0) 编辑
摘要: django-反向解析 views.py #url_反向解析 def test_url(request): return render(request,'test_url.html') def test_url_result(request): return HttpResponse(' 响应结果 阅读全文
posted @ 2021-08-04 19:12 yescarf 阅读(42) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 ··· 13 下一页