publish

Drf---ModelSerializer

*爱你&永不变心* 提交于 2019-12-01 14:15:36
多表设计 """ Book表:name、price、img、authors、publish、is_delete、create_time Publish表:name、address、is_delete、create_time Author表:name、age、is_delete、create_time AuthorDetail表:mobile, author、is_delete、create_time BaseModel基表 is_delete、create_time 上面四表继承基表,可以继承两个字段 """ 基表 class BaseModel(models.Model): is_delete = models.BooleanField(default=False) create_time = models.DateTimeField(auto_now_add=True) # 设置 abstract = True 来声明基表,作为基表的Model不能在数据库中形成对应的表 class Meta: abstract = True 断关联多表关系 知识点(重点) """ 1、外键位置: 一对多 - 外键放多的一方 一对一 - 从逻辑正反向考虑,如作者表与作者详情表,作者删除级联删除详情,详情删除作者依旧存在,所以建议外键在详情表中 多对多 - 外键在关系表中 2

drf-多表-ModelSerialize-序列化-反序列化

家住魔仙堡 提交于 2019-12-01 14:07:24
复习 """ 1、解析模块:全局局部配置 REST_FRAMEWORK = { # 全局解析类配置 'DEFAULT_PARSER_CLASSES': [ 'rest_framework.parsers.JSONParser', 'rest_framework.parsers.FormParser', 'rest_framework.parsers.MultiPartParser' ], } form rest_framework.parsers import JSONParser, FormParser class User(APIView): parser_classes = [JSONParser, FormParser] def get(): pass 2、异常模块 REST_FRAMEWORK = { # 全局配置异常模块 'EXCEPTION_HANDLER': 'api.exception.exception_handler', } def exception_handler(exc, context): response = drf views 中的 exception_handler 先处理 if response is None: 通过context,exc记录详细的异常信息 自己自定义响应对象 return Response({ 'detail':

序列化模块ModelSerializer

送分小仙女□ 提交于 2019-12-01 13:38:18
课程准备 配置:settings.py INSTALLED_APPS = [ # ... 'rest_framework', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'dg_proj', 'USER': 'root', 'PASSWORD': '123', } } """ 任何__init__文件 import pymysql pymysql.install_as_MySQLdb() """ LANGUAGE_CODE = 'zh-hans' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 路由 # 主 from django.conf.urls import url, include from django.contrib import admin from django.views.static import serve from django.conf import settings urlpatterns = [ url(r'

10.16总结

ぐ巨炮叔叔 提交于 2019-12-01 13:29:17
准备 配置:settings.py INSTALLED_APPS = [ # ... 'rest_framework', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'dg_proj', 'USER': 'root', 'PASSWORD': '123', } } """ 任何__init__文件 import pymysql pymysql.install_as_MySQLdb() """ LANGUAGE_CODE = 'zh-hans' TIME_ZONE = 'Asia/Shanghai' USE_I18N = True USE_L10N = True USE_TZ = False MEDIA_URL = '/media/' MEDIA_ROOT = os.path.join(BASE_DIR, 'media') 路由 # 主 from django.conf.urls import url, include from django.contrib import admin from django.views.static import serve from django.conf import settings urlpatterns = [ url(r'^admin

序列化组件之ModelSerializer和基类

谁说胖子不能爱 提交于 2019-12-01 13:24:15
多表设计 Book表:name、price、img、authors、publish、is_delete、create_time Publish表:name、address、is_delete、create_time Author表:name、age、is_delete、create_time AuthorDetail表:mobile, author、is_delete、create_time BaseModel基表 is_delete、create_time 上面四表继承基表,可以继承两个字段 基表 class BaseModel(models.Model): is_delete = models.BooleanField(default=False) create_time = models.DateTimeField(auto_now_add=True) # 设置 abstract = True 来声明基表,作为基表的Model不能在数据库中形成对应的表 class Meta: abstract = True 断关联多表关系 重点: 1、外键位置: 一对多 - 外键放多的一方 一对一 - 从逻辑正反向考虑,如作者表与作者详情表,作者删除级联删除详情,详情删除作者依旧存在,所以建议外键在详情表中 多对多 - 外键在关系表中 2、ORM正向方向连表查找: 正向:通过外键字段 eg:

Publish Gmail Addon Select Extension

牧云@^-^@ 提交于 2019-12-01 13:21:59
I am trying to publish Gmail Addon which I create before. I follow that documentation https://developers.google.com/gmail/add-ons/how-tos/publish#publish_an_add-on . According the documentation I am reaching the API Console from Resources > Cloud Platform project. And install the Google Apps Marketplace SDK. I cannot save Configuration because of extension selection. I cannot select Gmail Addon extension checkbox. You can see the image Do you have any idea how I can solve this? Cheers. Prasanth Janardanan This is a bug on that page. (can't save "Apps Marketplace SDK" Configuration for Gmail

ModelSerializer,序列化与反序列化整合

时光怂恿深爱的人放手 提交于 2019-12-01 13:20:38
复习 """ 1、解析模块:全局局部配置 REST_FRAMEWORK = { # 全局解析类配置 'DEFAULT_PARSER_CLASSES': [ 'rest_framework.parsers.JSONParser', 'rest_framework.parsers.FormParser', 'rest_framework.parsers.MultiPartParser' ], } form rest_framework.parsers import JSONParser, FormParser class User(APIView): parser_classes = [JSONParser, FormParser] def get(): pass 2、异常模块 REST_FRAMEWORK = { # 全局配置异常模块 'EXCEPTION_HANDLER': 'api.exception.exception_handler', } def exception_handler(exc, context): response = drf views 中的 exception_handler 先处理 if response is None: 通过context,exc记录详细的异常信息 自己自定义响应对象 return Response({ 'detail':

DRF多表设计与ModelSerializer组件

北城以北 提交于 2019-12-01 13:19:29
一:多表设计 (1)模型表字段 """ Book表:name、price、img、authors、publish、is_delete、create_time Publish表:name、address、is_delete、create_time Author表:name、age、is_delete、create_time AuthorDetail表:mobile, author、is_delete、create_time BaseModel基表 is_delete、create_time 上面四表继承基表,可以继承两个字段 """ PS:   (1)表格都有是否删除字段 创建时间字段   (2)抽象继承一个模型表(基表) (2)基表的创建 class BaseModel(models.Model): is_delete = models.BooleanField(default=False) create_time = models.DateTimeField(auto_now_add=True) # 设置 abstract = True 来声明基表,作为基表的Model不能在数据库中形成对应的表 重点 class Meta: abstract = True (3)断关联多表关系 (1)作用:   (1)物理上断开关系提升查找效率   (2)防止环装表关系 导致表关系成为死表

ElasticSearch 常用查询语句

我怕爱的太早我们不能终老 提交于 2019-12-01 11:39:05
为了演示不同类型的 ElasticSearch 的查询,我们将使用书文档信息的集合(有以下字段: title (标题), authors (作者), summary (摘要), publish_date (发布日期)和 num_reviews (浏览数))。 在这之前,首先我们应该先创建一个新的索引(index),并批量导入一些文档: 创建索引: PUT /bookdb_index { "settings": { "number_of_shards": 1 }} 批量上传文档: POST /bookdb_index/book/_bulk { "index": { "_id": 1 }} { "title": "Elasticsearch: The Definitive Guide", "authors": ["clinton gormley", "zachary tong"], "summary" : "A distibuted real-time search and analytics engine", "publish_date" : "2015-02-07", "num_reviews": 20, "publisher": "oreilly" } { "index": { "_id": 2 }} { "title": "Taming Text: How to Find,

Publish Gmail Addon Select Extension

孤街醉人 提交于 2019-12-01 11:30:12
问题 I am trying to publish Gmail Addon which I create before. I follow that documentation https://developers.google.com/gmail/add-ons/how-tos/publish#publish_an_add-on. According the documentation I am reaching the API Console from Resources > Cloud Platform project. And install the Google Apps Marketplace SDK. I cannot save Configuration because of extension selection. I cannot select Gmail Addon extension checkbox. You can see the image Do you have any idea how I can solve this? Cheers. 回答1: