上一页 1 2 3 4 5 6 ··· 8 下一页
摘要: django可以在每个子项目中添加自己的urls文件,然后再用include把路径包含进去 from django.contrib import admin from django.urls import path,include from example import urls #导入需要使用的u 阅读全文
posted @ 2019-11-16 22:30 颜颜blog 阅读(845) 评论(0) 推荐(0) 编辑
摘要: 表存在,可以通过django数据库反向生成来生成数据表model代码 在当前目录下执行命令,指定文件名为m.py python manage.py inspectdb > m.py ps:项目连接的哪个数据库,就生成哪个数据库的表代码 阅读全文
posted @ 2019-11-16 19:23 颜颜blog 阅读(245) 评论(0) 推荐(0) 编辑
摘要: PS:需要在setting中配置中间件的类路径 'my_test.middleware.SessionMiddleware',#校验session的类my_test 项目名称同名目录middleware 自定义的中间件py文件SessionMiddleware 实现中间件功能的类 from djan 阅读全文
posted @ 2019-11-16 19:08 颜颜blog 阅读(117) 评论(0) 推荐(0) 编辑
摘要: pickle--什么类型都可以转换成字符串 # pickle 什么类型都可以转成字符串 import pickle class MyCity: name = 'cd' city = MyCity() result = pickle.dumps(city)# 把对象转成字符串 print(result 阅读全文
posted @ 2019-11-16 19:04 颜颜blog 阅读(461) 评论(0) 推荐(0) 编辑
摘要: django自带用户系统 # django自带的用户系统 # auth_user表 from django.contrib.auth.models import AbstractUser from django.db import models # 自定义的用户表,继承自带的AbstractUser 阅读全文
posted @ 2019-11-16 19:03 颜颜blog 阅读(181) 评论(0) 推荐(0) 编辑
摘要: django数据库公共字段处理 创建好公共字段,其它数据库表继承这个基类就可以自动创建公共字段 # 数据库公共字段 ''' 1、枚举类型,值只能在这里面进行选择 创建表时,在字段属性里加上choices = is_delete_choice is_delete_choice = ( (0,'删除') 阅读全文
posted @ 2019-11-16 19:00 颜颜blog 阅读(827) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-11-15 13:40 颜颜blog 阅读(4) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-11-02 16:40 颜颜blog 阅读(25) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2019-11-02 11:41 颜颜blog 阅读(12) 评论(0) 推荐(0) 编辑
摘要: Django提供了一些函数,通过前端可以实现代码逻辑、字符串的处理等功能,一些复杂的功能如数据合法性判断、非法字符的过滤等可以通过后台代码实现前端自定义函数。 django提供了两种方法为前端实现自定义函数,分别是filter和simple_tag. 一、前端tag 后台代码 前端代码 替换敏感词- 阅读全文
posted @ 2019-11-01 14:47 颜颜blog 阅读(847) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 8 下一页