TypeError: Field 'amount' expected a number but got datetime.datetime(2022, 3, 27, 10, 46, 51, 801087, tzinfo=datetime.timezone.utc)

TypeError: Field 'amount' expected a number but got datetime.datetime(2022, 3, 27, 10, 46, 51, 801087, tzinfo=datetime.timezone.utc)

我觉得我做错了什么,我需要删除它。但我无法修复它。我该怎么做?

我迁移时遇到此错误

  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>

models.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),
    ),
]

删除数据库和所有迁移

再试一次