我想我做錯了什么,我需要洗掉它。但我無法修復它。我該怎么做?
我遷移并收到此錯誤
File "C:\Users\HP\Desktop\venv\lib\site-packages\django\db\models\fields\__init__.py", line
1990, in get_prep_value
raise e.__class__(
TypeError: Field 'amount' expected a number but got datetime.datetime(2022, 3, 27, 10, 46,
51, 801087, tzinfo=datetime.timezone.utc).
(venv) C:\Users\HP\Desktop\markon>
模型.py
class Product(models.Model):
name = models.CharField(max_length=100)
category = models.ForeignKey(Category, on_delete=models.DO_NOTHING)
images = models.ImageField(upload_to='product/%Y/%m/%d/')
detail = models.TextField()
keywords = models.CharField(max_length=50)
description = models.CharField(max_length=100)
price = models.FloatField()
sale = models.FloatField(blank=True, null=True)
amount = models.IntegerField(blank=True, null=True)
available = models.BooleanField(default=True)
date_created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.name
0008_product_amount.py 遷移檔案中的錯誤檔案
# Generated by Django 4.0.3 on 2022-03-27 10:46
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('product', '0007_remove_product_amount'),
]
operations = [
migrations.AddField(
model_name='product',
name='amount',
field=models.DateTimeField(blank=True, null=True),
),
]
uj5u.com熱心網友回復:
洗掉資料庫和所有遷移
然后再試一次
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/450243.html
上一篇:如何獲取與外鍵欄位關聯的所有物件
