小编Ale*_*sio的帖子

sql语句错误:"列..不存在"

我试着从postgres控制台这个命令:

select sim.id as idsim, 
       num.id as idnum 
from main_sim sim 
  left join main_number num on (FK_Numbers_id=num.id);
Run Code Online (Sandbox Code Playgroud)

我得到了这样的答复:

ERROR:  column "fk_numbers_id" does not exist
LINE 1: ...m from main_sim sim left join main_number num on (FK_Numbers...

但如果我只是检查我的表:

dbMobile=# \d main_sim

 id              | integer               | not null default

 Iccid           | character varying(19) | not null

...

 FK_Device_id    | integer               | 

 FK_Numbers_id   | integer               | 

Indexes:
    "main_sim_pkey" PRIMARY KEY, btree (id)
    "main_sim_FK_Numbers_id_key" UNIQUE, btree ("FK_Numbers_id")
    "main_sim_Iccid_key" UNIQUE, btree ("Iccid")
    "main_sim_FK_Device_id" btree ("FK_Device_id") …
Run Code Online (Sandbox Code Playgroud)

sql postgresql quoted-identifier

9
推荐指数
1
解决办法
3万
查看次数

无法使用Django从其他应用程序导入模型

我在尝试从另一个应用程序导入模型时遇到了麻烦.我有两个应用程序"主要"和"管理".在这里代码,我删除了一些冗长的描述:

"行政"模式:

from django.db import models
from django import forms
from django.forms import ModelForm


class Contract(models.Model):
    Code = models.CharField(max_length=50)
    Provider = models.CharField(max_length=30)
    Description = models.CharField(max_length=30)
    ActivationDate = models.DateField(blank=True, null=True)
    EndingDate = models.DateField(blank=True, null=True)
    Note = models.TextField(blank=True)
    Numbers = models.ManyToManyField('main.Number', through='Crefcontr2num')

def __unicode__(self):
    return u'%s %s' % (self.Provider, self.Description)

class Crefcontr2num(models.Model):
    Dateto = models.DateField()
    Datefrom = models.DateField()
    Contract = models.ForeignKey('Contract')
    Num = models.ForeignKey('main.Number')
Run Code Online (Sandbox Code Playgroud)

"主要"型号:

from django.db import models
from endusers.models import OrderedEndUser
from django import forms
from django.forms import ModelForm, Textarea, …
Run Code Online (Sandbox Code Playgroud)

python django import model

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

django ×1

import ×1

model ×1

postgresql ×1

python ×1

quoted-identifier ×1

sql ×1