Bu hatayı alıyorum; Bu anlamıyorum nemanage.py geçiş prodcution etkin değil ... sütun X var ... neden?
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.
, ben null=true
ve blank=true
olarak ayarlayın .... ve bu yerel kalkınma sunucusunda çalıştı. hata yalnızca üretimde oluştuğunu (ı elastik fasulye kullanıyorum)
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)
Düzenleme:. Bu benim piton yapılandırma dosyası taşımam var gördüğünüz gibi,
olduğunu
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
Benim traceback
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...
^
taşıma işlemim dosyası
0 o değerlendirilen değil böyleceFile "/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
çözüm bu kodu yeniden yazmak ya, ya:
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)),
],
),
Eğer üretim ortamında modelleri mevcut durumu ile 'makemigrations' ve' migrate' çalıştırmak mı? Geçiş dosyasını sürüm oluşturma işlemine tabi tuttuğunuzdan emin oldum (bazen bunu unutuyorum;))? – schwobaseggl
Hatanın başka bir yerden olduğuna inanıyorum. Tam stacktrace'i gönderir misin? – Abhinav
Sen göçler klasör de elastik Beanstalk da ayarlar yorum için teşekkür @schwobaseggl .ebextensions klasörünün – Aquiles