【发布时间】:2020-06-29 05:14:40
【问题描述】:
我正在尝试将耐用规则与我的 django restframework api 集成
我需要一些关于如何进行此操作的指导
比方说,我有一个班级学校、班级学生、班级地点
class School(models.Model):
schoolname = models.CharField(max_length=200)
class Location(models.Model):
locationname = models.CharField(max_length=200)
class Student(models.Model):
school = models.ForeignKey(School)
location = models.ForeignKey(Location)
studentname = models.CharField(max_length=200)
fees = models.IntegerField()
现在,我想制定规则说
if (schoolname = 'ABC' and location = 'xyz') then update fees = 1000
if (schoolname = 'SDS' and location = 'sdfs') then update fees = 200
如何使用耐用规则执行此操作?我的问题是我在哪里为它编写代码,在视图或序列化程序中。
任何示例代码都会有很大帮助
谢谢
现在以学校为准
【问题讨论】:
标签: python-3.x django-rest-framework rule-engine durable-rules