为了账号安全,请及时绑定邮箱和手机立即绑定

如何将下面的 SQL 状态转换为 Django ORM

如何将下面的 SQL 状态转换为 Django ORM

GCT1015 2021-10-19 09:48:29
很难将下面的 SQL 语句转换为 Django ORM。任何帮助深表感谢。SELECT a.state,        a.city,        a.postcode,        b.rate_authority,        b.rate,        b.rate_descr FROM   fileload_taxratemodel AS a        INNER JOIN fileload_taxrateresponsemodel AS b                ON b.jurs_id_id = a.id ORDER  BY state ASC Django 模型:尝试根据外键从两个模型中提取字段。class TaxRateModel(models.Model):company_code = models.CharField(max_length = 10)document_date = models.DateTimeField()country = models.CharField(max_length = 30, default = "US")province = models.CharField(max_length = 100, null= True,blank= True)state = models.CharField(max_length = 100)county = models.CharField(max_length = 100,blank=True, null=True)city = models.CharField(max_length = 100,blank=True, null=True)district = models.CharField(max_length = 100, blank=True, null=True)postcode = models.CharField(max_length = 5, blank=True, null=True)rate_code = models.CharField(max_length = 30,default = "ST")Django 2 模型:class TaxRateResponseModel(models.Model):jurs_id = models.ForeignKey(TaxRateModel,on_delete=models.CASCADE,related_name='rates')rate_authority = models.CharField(max_length = 100, blank=True, null=True, default='')rate_descr = models.CharField(max_length = 100, blank=True, null=True, default ='')rate = models.DecimalField(max_digits= 10, decimal_places=5)
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 203 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信