私はpy manage.py makemigrations
を試してからpy manage.py migrate
を試みましたが、私のモデルに新しいフィールドを追加するとこのエラーが発生します。私はまた、すべての移行を削除してmakemigrationsをやってみて、もう一度移行しようとしましたが、それでも問題は解決しません。django 1.11 - OperationalErrorそのような列はありません
基本的に私がモデルSchedule
を持っていると私は関係がcustomer = models.ForeignKey(Customer)
EDITであることにCustomer
フィールドを追加しました:ここに私のモデルがある
class Schedule(models.Model):
name = models.CharField(max_length=250)
deadline_date = models.DateField()
is_completed = models.BooleanField(default=False)
description = models.CharField(max_length=1000, default="")
customer = models.ForeignKey(Customer)
編集:ここでは、移行
class Migration(migrations.Migration):
initial = True
dependencies = [
('core', '0007_customer'),
]
operations = [
migrations.CreateModel(
name='Schedule',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=250)),
('deadline_date', models.DateField()),
('deadline_time', models.TimeField()),
('is_completed', models.BooleanField(default=False)),
('description', models.CharField(default='', max_length=1000)),
('responsible_department', models.CharField(choices=[('Inventory', 'Inventory'), ('Sales', 'Sales'), ('Procurement', 'Procurement'), ('Accounting', 'Accounting'), ('Technical', 'Technical'), ('Admin', 'Admin')], default='Sales', max_length=30)),
('customer', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.Customer')),
],
),
]
があります
トレースバックは次のとおりです。
Traceback:
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\utils.py" in execute
65. return self.cursor.execute(sql, params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\sqlite3\base.py" in execute
328. return Database.Cursor.execute(self, query, params)
The above exception (no such column: schedule_schedule.customer_id) was the direct cause of the following exception:
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\exception.py" in inner
41. response = get_response(request)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\contrib\admin\options.py" in wrapper
551. return self.admin_site.admin_view(view)(*args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\views\decorators\cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\contrib\admin\sites.py" in inner
224. return view(request, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\decorators.py" in _wrapper
67. return bound_func(*args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\decorators.py" in bound_func
63. return func.__get__(self, type(self))(*args2, **kwargs2)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\contrib\admin\options.py" in changelist_view
1662. selection_note=_('0 of %(cnt)s selected') % {'cnt': len(cl.result_list)},
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\models\query.py" in __len__
232. self._fetch_all()
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\models\query.py" in _fetch_all
1118. self._result_cache = list(self._iterable_class(self))
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\models\query.py" in __iter__
53. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\models\sql\compiler.py" in execute_sql
894. raise original_exception
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\models\sql\compiler.py" in execute_sql
884. cursor.execute(sql, params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\utils.py" in execute
80. return super(CursorDebugWrapper, self).execute(sql, params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\utils.py" in execute
65. return self.cursor.execute(sql, params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\utils\six.py" in reraise
685. raise value.with_traceback(tb)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\utils.py" in execute
65. return self.cursor.execute(sql, params)
File "C:\Program Files (x86)\Python36-32\lib\site-packages\django-1.11.4-py3.6.egg\django\db\backends\sqlite3\base.py" in execute
328. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /admin/schedule/schedule/
Exception Value: no such column: schedule_schedule.customer_id
移行する際にエラーがありますか? '--fake-initial'で移行しようとしましたか? – souldeux
モデル全体を確認できますか? – scharette
@souldeux移行時にエラーはありません。 --fake –