Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django和Pipelinedb:编程错误:列<;数据库名称>;。位置\u id不存在_Django_Postgresql_Pipelinedb - Fatal编程技术网

Django和Pipelinedb:编程错误:列<;数据库名称>;。位置\u id不存在

Django和Pipelinedb:编程错误:列<;数据库名称>;。位置\u id不存在,django,postgresql,pipelinedb,Django,Postgresql,Pipelinedb,我正在使用Django和postgresdb进行一个项目,其中流式数据使用pipelinedb输入。同步脚本正在运行此脚本。所有的东西都是固定的 测试服务器上的数据每60秒更新一次 我将此字段添加到模型中: location = models.ForeignKey('Location', related_name='assigned_sensor', on_delete=models.CASCADE, null=True) 以下是天气和位置模型供参考: class WeatherStatsMr

我正在使用Django和postgresdb进行一个项目,其中流式数据使用pipelinedb输入。同步脚本正在运行此脚本。所有的东西都是固定的

测试服务器上的数据每60秒更新一次

我将此字段添加到模型中:

location = models.ForeignKey('Location', related_name='assigned_sensor', on_delete=models.CASCADE, null=True)
以下是天气和位置模型供参考:

class WeatherStatsMrel(models.Model):
    id = models.BigIntegerField(db_column='$pk', primary_key=True)
    loc = models.CharField(max_length=3, null=True)
    dat = models.DateField(blank=True, null=True, editable=True)
    tim = models.TimeField(blank=True, null=True, editable=False)
    aws = models.FloatField(blank=True, null=True, editable=False)
    awd = models.TextField(blank=True, null=True, editable=False)
    mws = models.FloatField(blank=True, null=True,editable=False)
    mwd = models.TextField(blank=True, null=True,editable=False)
    tmp = models.FloatField(blank=True, null=True,editable=False)
    hum = models.FloatField(blank=True, null=True,editable=False)
    r10 = models.FloatField(blank=True, null=True,editable=False)
    r60 = models.FloatField(blank=True, null=True,editable=False)
    rda = models.FloatField(blank=True, null=True,editable=False)
    rcu = models.TextField(blank=True, null=True,editable=False)
    rad = models.TextField(blank=True, null=True,editable=False)
    sun = models.TextField(blank=True, null=True,editable=False)
    location = models.ForeignKey('Location', related_name='assigned_sensor', on_delete=models.CASCADE, null=True)

    class Meta:
        db_table = 'weather_stats_mrel'


    def __unicode__(self):
        return str({self.loc}, {self.dat}, {self.tim}, {self.aws}, {self.awd}, {self.mws}, {self.mwd}, {self.tmp}, {self.hum}, {self.r10}, {self.r60}, {self.rda}, {self.rcu}, {self.rad}, {self.sun})    

class Location(models.Model):
    id = models.AutoField(primary_key=True)
    abbreviated_name = models.CharField(max_length=3)
    full_name = models.CharField(max_length=25)

    def __str__(self):
        return self.abbreviated_name
当我启动服务器时,一切正常。通过管理页面(Django的默认管理页面),我可以导航到weather_stats_mrel页面,尝试查看传入的数据

但是,一旦Pipelindb更新了表,当我尝试查看页面时,会出现以下错误:

ProgrammingError at /admin/test_sensor_app/weatherstatsmrel/
column weather_stats_mrel.location_id does not exist
LINE 1: ...er_stats_mrel"."rad", "weather_stats_mrel"."sun", "weather_s...
                                                             ^
Request Method: GET
Request URL:    http://localhost:8000/admin/test_sensor_app/weatherstatsmrel/
Django Version: 2.1.1
Exception Type: ProgrammingError
Exception Value:    
column weather_stats_mrel.location_id does not exist
LINE 1: ...er_stats_mrel"."rad", "weather_stats_mrel"."sun", "weather_s...
                                                             ^
据我所知,Django应该自动添加这个字段,对吗?还是现在需要手动添加此表?我应该把它放在模型里的什么地方

我以前在使用foreignkey时从来没有遇到过这个问题,但是,这是我第一次使用在Django接触它之前预先生成的表


这个问题有解决办法吗?以前有人遇到过这种情况吗?

看起来您有一个名为
天气统计的连续视图。无法向现有连续视图中添加列,因此除非在连续视图的定义中包含
location\u id
,否则该列将不存在