关系“ pages_page”不存在

时间:2018-08-04 05:55:29

标签: python django

我正在尝试使用Django创建想法登录页面,这将允许我发布页面并收集电子邮件地址。正确,我的应用程序已启动,运行时一切正常:

python manage.py runserver

heroku local web

但是,当我尝试部署到Heroku并运行时;

heroku run python manage.py loaddata pages.json

我遇到了我似乎无法解读或修复的错误:

    Traceback (most recent call last):
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: column "show_nav" of relation "pages_page" does not exist
LINE 17:       </div>', "show_nav" = true, "nav_color" = '#820000', "...
                        ^


The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 305, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/base.py", line 356, in execute
    output = self.handle(*args, **options)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 64, in handle
    self.loaddata(fixture_labels)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 104, in loaddata
    self.load_label(fixture_label)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 167, in load_label
    obj.save(using=self.using)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/core/serializers/base.py", line 201, in save
    models.Model.save_base(self.object, using=using, raw=True, **kwargs)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 824, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 889, in _save_table
    forced_update)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/base.py", line 939, in _do_update
    return filtered._update(values) > 0
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/query.py", line 652, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1148, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 835, in execute_sql
    cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "/app/.heroku/python/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: Problem installing fixture '/app/pages.json': Could not load pages.Page(pk=1): column "show_nav" of relation "pages_page" does not exist
LINE 17:       </div>', "show_nav" = true, "nav_color" = '#820000', "...

我认为这必须与我的models.py页面有关

from django.db import models
from django.core.exceptions import ValidationError 
# Create your models here.

LAYOUT_CHOICES = (
    ('standard', 'Standard'),
    ('stacked', 'Stacked'),
)

def layout_validator(value):
    if value[0] != "#":
        raise ValidationError("Must start with #")
    if len(value) == 4 or len(value) == 7:
        return value
    raise ValidationError("Incorrect length")

class Page(models.Model):
    title = models.CharField(max_length=225)
    title_description = models.TextField(blank=True, null=True)
    title_btn = models.CharField(max_length=50, default='Join')
    title_btn_url = models.CharField(max_length=50, blank=True, null=True)
    content = models.TextField(blank=True, null=True)
    show_nav = models.BooleanField(default=True, help_text='Show Navigation Bar?')
    nav_color = models.CharField(max_length=7, default='#000000')
    layout = models.CharField(max_length=20, choices=LAYOUT_CHOICES, default='standard')
    video_embed = models.TextField(null=True, blank=True)

    def __str__(self):
        return self.title

我试图删除pages.json并从头开始。我尝试进行新的迁移。如果有人对这个“ pages_page关系”不存在什么错误有任何帮助,将不胜感激?

0 个答案:

没有答案