摘要: 我们现在在工程目录/meiduo_mall/apps中创建Django应用users,并在配置文件中注册users应用。 python manage.py startapp users > INSTALL_APPS注册 class User(AbstractUser): """用户模型类""" mo 阅读全文
posted @ 2020-02-24 14:04 阿里云的奥斯卡 阅读(159) 评论(0) 推荐(0) 编辑
摘要: 1、安装 pip install djangorestframework 2、创建工程 添加framework应用 setting.py INSTALLED_APPS = [ ... 'rest_framework', ] 3、定义serializers.py from rest_framework 阅读全文
posted @ 2020-02-20 08:06 阿里云的奥斯卡 阅读(272) 评论(0) 推荐(0) 编辑
摘要: # 自定义模型类 管理器使用方法 class BookInfoManager(model.Manager): # 重写all def all(self): return self.filter(is_delete=False) class BookInfo(): ................ # 阅读全文
posted @ 2020-02-19 08:48 阿里云的奥斯卡 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2020-02-17 18:23 阿里云的奥斯卡 阅读(111) 评论(0) 推荐(0) 编辑
摘要: 响应信息:起始行,响应头,响应体 视图接收请求并处理后,必须返回HttpResponse对象或子对象 HttpResponse(content=响应体,content_type=相应数据类型,status=状态码) # 默认200 状态码 JsonResponse 相应信息返回json字符串 ret 阅读全文
posted @ 2020-02-17 17:30 阿里云的奥斯卡 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 创建子应用 users 》flask register python manage.py startapp users # 注册应用 views --> 定义视图 urls --> 定义路径和映射关系 全局.urls --> 包含子应用路径 配置、静态文件与路由 1、base_dir 索引根路径 2 阅读全文
posted @ 2020-02-17 08:25 阿里云的奥斯卡 阅读(141) 评论(0) 推荐(0) 编辑
摘要: web 框架学习要点 1、如何搭建工程程序 工程组件 > 工程配置 > 路由定义 > 视图函数定义 2、如何操作请求request数据 3、如何构造相应response数据 4、如何使用中间层 5、框架使用其他功能组件 1、数据库 2、模板 3、表单 4、admin 等 特点 : 一、重量级框架 相 阅读全文
posted @ 2020-02-16 20:38 阿里云的奥斯卡 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 通过命令行执行 创建superuser 账户 @manager.option('-n', '-name', dest="name") @manager.option('-p', '-password', dest="password") def createsuperuser(name, passw 阅读全文
posted @ 2020-02-13 21:42 阿里云的奥斯卡 阅读(374) 评论(0) 推荐(0) 编辑
摘要: try: # time.localtime() 返回一个时间对象 t.tm_year年 t.tm_mon 月份 t = time.localtime() # datetime.strptime(时间,格式format) 返回一个时间 %02d补全两位数 begin_mon_date = dateti 阅读全文
posted @ 2020-02-13 21:39 阿里云的奥斯卡 阅读(1128) 评论(0) 推荐(0) 编辑
摘要: 报错: UnboundLocalError: local variable 'total_page' referenced before assignment news_list = [] # 修改 total_page =1 current_page = 1 try: paginate = use 阅读全文
posted @ 2020-02-13 07:57 阿里云的奥斯卡 阅读(920) 评论(0) 推荐(0) 编辑