在中使用Oracle视图时遇到问题型号.py

2024-03-28 09:39:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我和我的小组正试图重写我们的网站。我们正在保留一个Oracle数据库后端,并用pythondjango重写前端。你知道吗

连接到Oracle或访问数据表时没有问题。现在我正在尝试将Oracle视图添加到型号.py,但我不能让它工作。你知道吗

我在google上搜索了这个问题,得到了很多结果,所以我知道这是可能的,而且很常见,但我无法让它发挥作用。你知道吗

到目前为止,我所做的只是将类添加到型号.py. 我们使用PhCharm作为IDE。你知道吗

当我尝试使用Python控制台访问数据时,我可以导入类,但是当我尝试加载QuerySet时,在结果窗口中出现错误“Unable to get repr for”。你知道吗

有人看到我的模型里少了什么吗?你知道吗

模型如下:

class LawBillRoleActionInfoView(LawBaseClass):
    combo_id = models.AutoField(primary_key=True)
    rltp_role_cd = models.CharField(max_length=2, blank=True)
    bill_dft_no = models.CharField(max_length=6, blank=True)
    session_id = models.IntegerField(blank=True, null=True)
    ebrl_appl_seq = models.IntegerField(blank=True, null=True)
    enty_id_seq = models.IntegerField(blank=True, null=True)
    lst_nm = models.CharField(max_length=100, blank=True)
    fst_nm = models.CharField(max_length=40, blank=True)
    mi = models.CharField(max_length=1, blank=True)
    entity = models.CharField(max_length=145, blank=True, null=True)
    prtydist = models.CharField(max_length=11, blank=True, null=True)
    blac_appl_seq = models.IntegerField(blank=None, null=True)
    role_descr = models.CharField(max_length=80, blank=True)
    shr_ttl = models.CharField(max_length=80, blank=True)
    lmt_ind = models.CharField(max_length=1, blank=True)
    bltp_bill_typ_cd = models.CharField(max_length=2, blank=True)
    bill_no = models.IntegerField(blank=True, null=True)
    actn_descr = models.CharField(max_length=80, blank=True)
    actn_dt = models.DateField(blank=True, null=True)
    sess_law_chpt_no = models.IntegerField(blank=True, null=True)

class Meta:
    managed = False
    db_table = 'law_bill_role_action_info_vw'
    unique_together = (('bill_dft_no', 'rltp_role_cd', 'session_id'),)
    app_label = 'laws'

下面是我从Python控制台运行的命令:

from laws.models import LawBillRoleActionInfoView
bill_qs = LawBillRoleActionInfoView.objects.all()

以下是LawBaseClass:

基类

class LawBaseClass(models.Model):
    """
    Base class
    """
    created_by = models.CharField(max_length=30, blank=True, null=True)
    dtm_created = models.DateField(blank=True, null=True)
    mod_by = models.CharField(max_length=30, blank=True, null=True)
    dtm_mod = models.DateField(blank=True, null=True)

class Meta:
    managed = False
    abstract = True

Tags: noidtruemodelsnulllengthmaxclass