class RiskLevel_Months(models.Model):
"""
每月风险等级表 --nzy
"""
levels = (('0', '无风险'), ('1', '中等风险'), ('2', '高风险'))
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False, verbose_name=u'编号', help_text=u'编号')
# month = models.CharField(max_length=50, choices=months, verbose_name=u'月份', help_text=u'月份', null=True, blank=True)
# level = models.CharField(max_length=50, choices=levels, verbose_name=u'等级', help_text=u'等级', default='0')
biological_risk = models.OneToOneField(BiologicalRisk, verbose_name="海洋生物风险ID", help_text="海洋生物风险ID",
on_delete=models.CASCADE, related_name="biological_risk_month")
Jan = models.CharField(max_length=8, choices=levels, verbose_name=u'一月', help_text=u'一月', default='0')
Feb = models.CharField(max_length=8, choices=levels, verbose_name=u'二月', help_text=u'二月', default='0')
Mar = models.CharField(max_length=8, choices=levels, verbose_name=u'三月', help_text=u'三月', default='0')
Apr = models.CharField(max_length=8, choices=levels, verbose_name=u'四月', help_text=u'四月', default='0')
May = models.CharField(max_length=8, choices=levels, verbose_name=u'五月', help_text=u'五月', default='0')
Jun = models.CharField(max_length=8, choices=levels, verbose_name=u'六月', help_text=u'六月', default='0')
Jul = models.CharField(max_length=8, choices=levels, verbose_name=u'七月', help_text=u'七月', default='0')
Aug = models.CharField(max_length=8, choices=levels, verbose_name=u'八月', help_text=u'八月', default='0')
Sept = models.CharField(max_length=8, choices=levels, verbose_name=u'九月', help_text=u'九月', default='0')
Oct = models.CharField(max_length=8, choices=levels, verbose_name=u'十月', help_text=u'十月', default='0')
Nov = models.CharField(max_length=8, choices=levels, verbose_name=u'十一月', help_text=u'十一月', default='0')
Dec = models.CharField(max_length=8, choices=levels, verbose_name=u'十二月', help_text=u'十二月', default='0')
@classmethod
def high_risk_biolog(cls): #获取所有数据中当前月份的高风险生物
return cls.objects.filter(**{datetime.now().strftime('%b'): cls.levels[2][0]}).values('biological_risk')
class Meta:
db_table = 'envidata_risklevel_months'
verbose_name = "每月风险等级表"
verbose_name_plural = verbose_name
def __str__(self):
return str(self.id)
类属性查询法
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...