I think I did something wrong and I need to delete it. but i can't fix it. How can I do it?
I migrate and I get this error
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 error file in migrations file
# 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),
),
]
CodePudding user response:
Delete the database and all migrations
and try again