https://blog.csdn.net/Ayhan_huang/article/details/78626957

一、ContenType

from django.db import models
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.fields import GenericForeignKey,GenericRelation
# Create your models here.
class Electrics(models.Model):
name =models.CharField(max_length=)
price =models.IntegerField(default= )
coupons =GenericRelation(to ="Coupon") def __str__(self):
return self.name class Clothes(models.Model):
name =models.CharField(max_length=)
price =models.IntegerField(default= )
coupon =GenericRelation(to ="Coupon") def __str__(self):
return self.name class Foods(models.Model):
name =models.CharField(max_length=)
price =models.IntegerField(default=)
coupons =GenericRelation(to="Coupon") def __str__(self):
return self.name class Coupon(models.Model):
name = models.CharField(max_length=) content_type =models.ForeignKey(to=ContentType) #step
object_id =models.PositiveIntegerField() #step
content_object =GenericForeignKey("content_type","object_id") # step def __str__(self):
return self.name # electics_obj =models.ForeignKey(to = "Foods",null=True)
# food_obj =models.ForeignKey(to ="Foods",null=True)
# cloth_obj =models.ForeignKey(to="Clothes",null=True) """
Coupon id name content_type_id object_id
冰箱满减优惠 """

views

from django.shortcuts import render,HttpResponse
from App01 import models
# Create your views here. def index(request):
# 为三星电视(id=2)创建一条优惠记录
# s_bingxiang = models.Electrics.objects.filter(id=2).first()
# models.Coupon.objects.create(name='电冰箱优惠券', content_object=s_bingxiang)
# models.Coupon.objects.create(name='猪蹄优惠券', content_type_id=10, object_id=1) #查询猪蹄买一送一优惠券对应商品的价格
coupon =models.Coupon.objects.filter(name="猪蹄优惠券").first() #美的冰箱所有优惠券的名字
meidi=models.Electrics.objects.filter(name ="美的冰箱").first()
return HttpResponse("ok")

  

二、支付宝接口

1.私钥是不能公开,一个公钥对应一个私钥。

2. 秘钥 对中 ,让大家知道的是公钥,不要告诉大家只有自己知道的是私钥。

day106 支付功能与优惠券功能 contentype的更多相关文章

  1. newbee-mall 开源商城新计划:秒杀功能、优惠券、对接支付宝

    新项目是 newbee-mall 的升级版本,暂时就叫它 newbee-mall-plus 吧,第一阶段会开发秒杀功能.优惠券.对接支付宝这些功能,也会慢慢加入 Redis. Elastic Sear ...

  2. 新增秒杀功能、优惠券、支付宝、Docker,newbee-mall升级版开源啦!

    最近是非常非常非常忙,一方面是公司的事情比较多,另外⼀点是最近在准备诉讼材料.⾄于诉讼的是谁,⼤家可以去看我之前写的几篇文章,所以本来这周是不打算更新文章的.不过,昨天慕课网的法务联系我的律师了,终于 ...

  3. WPF4.5 中的新增功能和增强功能的信息

    本主题包含有关 Windows Presentation Foundation (WPF) 版本 4.5 中的新增功能和增强功能的信息. 本主题包含以下各节: 功能区控件 改善性能,当显示大时设置分组 ...

  4. JMessage是让App 同时集成 Push 功能与 IM 功能最完美的方案

    历经几个月的沉寂,以及兄弟们的奋战,极光推送的兄弟产品诞生了:极光IM,英文名 JMessage. 极光IM 是我们团队基于大量客户的需求反馈,在很多客户的殷切期盼下所开发的.团队成员一方面要支撑极光 ...

  5. spring boot集成websocket实现聊天功能和监控功能

    本文参考了这位兄台的文章: https://blog.csdn.net/ffj0721/article/details/82630134 项目源码url: https://github.com/zhz ...

  6. (三)微信小程序首页的分类功能和搜索功能的实现笔记

    就在昨天,微信宣布了微信小程序开发者工具新增“云开发”功能 下载最新的开发者工具,现在无需服务器即可实现小程序的快速迭代! 分类功能和搜索功能的效果图 1.首页分类功能的实现 boxtwo方法(.js ...

  7. X5webview完美去掉分享功能和缓存功能(2)

    前段时间比较忙,没有来得及写完如何将X5WEBVIEW分享功能和缓存功能屏蔽,下面直接来干货,上代码. 1.首先在布局文件中增加一个全屏的布局, <!-- 视频全屏--> <Fram ...

  8. X5webview去掉分享功能和缓存功能

    x5webview比原生的webview适配更好,加载更快,对音视频的兼容性更好,具备独特的优势 1) 速度快:相比系统webview的网页打开速度有30+%的提升: 2) 省流量:使用云端优化技术使 ...

  9. 系统管理模块_岗位管理_改进_使用ModelDroven方案_套用美工写好的页面效果_添加功能与修改功能使用同一个页面

    改进_使用ModelDroven方案 @Controller @Scope("prototype") public class RoleAction extends ActionS ...

随机推荐

  1. eclipse 从git取项目,导入为maven项目,新加的方法,报加载主类错误

    eclipse 从git取项目,导入为maven项目,新加的方法,报加载主类错误 具体描述: 整体编译能够编译成功,但新加一个java,里面创建一个main方法,运行时,报无法加载主类的错误, 整体编 ...

  2. Solution for NULL pointer dereference

    •mmap_min_addr forbids users from mapping low addresses 1. First available in July 2007 2. Several c ...

  3. CentOS7.6系统安装zabbix3.4.8客户端

    一.     准备安装包 将本地的zabbix-3.4.8软件包上传至服务器, 二.     安装依赖包 安装依赖包:yum install gcc* pcre* psmisc -y 三.     安 ...

  4. 三、MVC_JsonResult类型

    一.Ajax或者页面请求获取数据,不通过WebApi的时候,使用JsonResult作为返回Json数据格式的类型 二.代码呈现 public class HomeController : Contr ...

  5. (ACM模板)集合set

    #include<iostream> #include<cstdio> #include<set> using namespace std; int main() ...

  6. Sass-@for

    在制作网格系统的时候,大家应该对 .col1~.col12 这样的印象较深.在 CSS 中你需要一个一个去书写,但在 Sass 中,可以使用 @for 循环来完成.在 Sass 的 @for 循环中有 ...

  7. TP、FP、FN、TN的含义

    true positive(被正确分类的正例) false negative(本来是正例,错分为负例) true negative(被正确分类的负例) false positive(本来是负例,被错分 ...

  8. setInterval,setTimeout,clearInterval

    定时器 var i=0; function iadd(){ i++; console.log(i) } setInterval(iadd,1000);//1.2.3... 超时调用 var i=0; ...

  9. Linux用户登出之后保持后台进程(nohup)

    使用&可以将进程置于后台,但是用户从Shell登出之后,进程会自动结束.想要在登出之后保持进程运行,就要结合nohup命令使用. 例如: nohup find -size +100k > ...

  10. 改计算机名导致 Oracle因目标主机或对象不存在

    手贱修改了计算机名, 结果导致登陆oracle数据库报如下错误,一查资料,说是修改了计算机名导致的,需要进到oracle安装目录: \oracle\product\10.2.0\db_1\NETWOR ...