問題は、Django と製品モデルを使用して e コマース アプリケーションを作成していることです。最初に、フィールドのタイトル、説明、価格を追加し、すべてのコマンド makemigrations、migrate を実行しましたが、すべて正常に機能していました。ここで、Image というフィールドを追加し、makemigrations を適用しようとすると、エラー django.db.utils.OperationalError: no such column: Products_product.image が発生します。
データベースを削除して再度作成し、移行フォルダーから移行履歴を削除するなど、提案されたすべてのソリューションをこれに適用しましたが、それでも機能しなかったため、新しいプロジェクトを再度作成する必要がありました。
新しいプロジェクトでは、このイメージフィールドの移行は最初の移行で問題なく機能し、注目の製品としてマークするために Featured(BOOLEAN FIELD) というフィールドを追加しましたが、問題が再び発生しました。そのイメージフィールドと同じ問題です。
django.db.utils.OperationalError:そのような列はありません:Products_product.featured
この問題についてインターネットを掘り下げるのに多くの時間を無駄にしましたが、どれも機能していませんか?助けてください?
これは私のモデルがどのように見えるかです
class Product(models.Model):
title = models.CharField(max_length = 100)
description = models.TextField()
price =models.DecimalField(decimal_places=2,max_digits=20,default=39.99)
image = models.ImageField(upload_to=upload_image_path,null=True,blank=True)
featured = models.BooleanField(default=False)
以下は、表示される完全なエラーです。
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\models\query.py", line 248, in __repr__
data = list(self[:REPR_OUTPUT_SIZE + 1])
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\models\query.py", line 272, in __iter__
self._fetch_all()
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\models\query.py", line 1179, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\models\query.py", line 53, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\models\sql\compiler.py", line 1067, in execute_sql
cursor.execute(sql, params)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\utils.py", line 100, in execute
return super().execute(sql, params)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\utils.py", line 89, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\utils.py", line 85, in _execute
return self.cursor.execute(sql, params)
File "C:\Users\vipul\AppData\Local\Programs\Python\Python36-32\lib\site-packages\django-2.0.4-py3.6.egg\django\db\backends\sqlite3\base.py", line 303, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such column: Products_product.featured'