我试着从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) 我在尝试从另一个应用程序导入模型时遇到了麻烦.我有两个应用程序"主要"和"管理".在这里代码,我删除了一些冗长的描述:
"行政"模式:
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)