0
このエラーが発生しています。manage.py migrateがprodcution ...でアクティブ化されていませんカラムXが存在しません...なぜですか?
ProgrammingError at/
column main_category.parent_cat_id does not exist
LINE 1: ...n_category"."author_id", "main_category"."image", "main_cate. and I believe this means parent_cat_id isn't in the database.
これは私がnull=true
とblank=true
に設定....これはローカルの開発サーバーで働いていた、私は理解していないものです。エラーが唯一の生産で発生している(私はElastic Beanstalkでを使用しています)
class Category(models.Model):
name = models.CharField(max_length=128, unique=True)
author = models.ForeignKey(settings.AUTH_USER_MODEL)
parent_cat = models.ForeignKey('self', null=True, blank=True)
hotCat = models.BooleanField(default=False)
active = models.BooleanField(default=True)
sponsored = models.ForeignKey(Sponsored, null=True, blank=True)
objects = CategoryManager()
def __unicode__(self):
return self.name
def get_absolute_url(self):
return "/category/%s/" %self.name
def get_image_url(self):
return "%s%s" %(settings.MEDIA_URL, self.image)
編集:これは私のpythonの設定ファイルには、あなたは、私が移動してい見ることができるように、
ある
container_commands:
01_migrate:
command: "source /opt/python/run/venv/bin/activate && python myproject/manage.py migrate --noinput"
leader_only: true
02_uninstall_pil:
command: "source /opt/python/run/venv/bin/activate && yes | pip uninstall Pillow"
03_reinstall_pil:
command: "source /opt/python/run/venv/bin/activate && yes | pip install Pillow --no-cache-dir"
04_createsu:
command: "source /opt/python/run/venv/bin/activate && python myproject/manage.py createsu"
leader_only: true
05_collectstatic:
command: "source /opt/python/run/venv/bin/activate && python myproject/manage.py collectstatic --noinput"
06_checkpermission:
command: "source /opt/python/run/venv/bin/activate && python myproject/manage.py check_permissions"
option_settings:
"aws:elasticbeanstalk:application:environment":
DJANGO_SETTINGS_MODULE: "myproject.settings"
"PYTHONPATH": "/opt/python/current/app/myproject:$PYTHONPATH"
"aws:elasticbeanstalk:container:python":
WSGIPath: myproject/myproject/wsgi.py
私のトレースバック
Traceback:
File "/opt/python/run/venv/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
132. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/python/current/app/myproject/main/views.py" in index
64. request.session['categories'] = [ c.name for c in Category.objects.filter(author=request.user.id)] # add to the session
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
162. self._fetch_all()
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
965. self._result_cache = list(self.iterator())
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/query.py" in iterator
238. results = compiler.execute_sql()
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
840. cursor.execute(sql, params)
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
79. return super(CursorDebugWrapper, self).execute(sql, params)
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/utils.py" in __exit__
97. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/opt/python/run/venv/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
64. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at/
Exception Value: column main_category.parent_cat_id does not exist
LINE 1: ...n_category"."author_id", "main_category"."image", "main_cate...
^
マイ移行ファイル
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(unique=True, max_length=128)),
('description', models.TextField(verbose_name=b'\xec\xbb\xa4\xeb\xae\xa4\xeb\x8b\x88\xed\x8b\xb0 \xec\x84\xa4\xeb\xaa\x85')),
('image', models.ImageField(upload_to=b'images/', null=True, verbose_name=b'\xec\xbb\xa4\xeb\xae\xa4\xeb\x8b\x88\xed\x8b\xb0 \xeb\x8c\x80\xed\x91\x9c \xec\x9d\xb4\xeb\xaf\xb8\xec\xa7\x80', blank=True)),
('hotCat', models.BooleanField(default=False)),
('active', models.BooleanField(default=True)),
('author', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
('parent_cat', models.ForeignKey(blank=True, to='main.Category', null=True)),
],
),
実稼働環境でモデルの現在の状態で 'makemigrations'と' migrate'を実行しましたか?移行ファイルをバージョン管理にコミットしたことを確認しました(私はそれを忘れることもあります))? – schwobaseggl
私はこのエラーが他のどこかから来たと信じています。完全なスタックトレースを投稿できますか? – Abhinav
あなたのMigrationsフォルダに最新の移行が含まれていることを確認する必要があります。また、弾力のあるbeanstalkの設定には、.ebextensionsフォルダのpython.configにあるmanage.py migrate your_appを使用することが含まれています – Aquiles