class Cart(Model, ModelUtilMixin):
id = fields.BigIntField(pk=True, auto_increment=True)
user = fields.TextField(null=True)
address = fields.BigIntField(null=True)
cashback = fields.BooleanField(default=True)
coupon = fields.TextField(null=True)
order_id = fields.TextField(null=True)
location = fields.TextField(null=True)
client = fields.TextField(null=True)
mrp = fields.FloatField(default=0)
type = fields.TextField(default='pharmacy')
eligible_for = fields.BooleanField(null=True)
variant = fields.TextField(null=True)
meta_info = fields.JSONField(null=True)
created = fields.DatetimeField(auto_now_add=True)
updated = fields.DatetimeField(auto_now=True)
class Meta:
table = 'cart'
now it's throwing error for for created field
Traceback (most recent call last):
File "/Users/ram/env/bin/aerich", line 8, in
sys.exit(main())
File "/Users/ram/env/lib/python3.8/site-packages/aerich/cli.py", line 298, in main
cli()
File "/Users/ram/env/lib/python3.8/site-packages/click/core.py", line 1137, in call
return self.main(args, kwargs)
File "/Users/ram/env/lib/python3.8/site-packages/click/core.py", line 1062, in main
rv = self.invoke(ctx)
File "/Users/ram/env/lib/python3.8/site-packages/click/core.py", line 1668, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/ram/env/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, ctx.params)
File "/Users/ram/env/lib/python3.8/site-packages/click/core.py", line 763, in invoke
return __callback(args, kwargs)
File "/Users/ram/env/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
return f(get_current_context(), *args, *kwargs)
File "/Users/ram/env/lib/python3.8/site-packages/aerich/cli.py", line 41, in wrapper
loop.run_until_complete(f(args, kwargs))
File "uvloop/loop.pyx", line 1494, in uvloop.loop.Loop.run_until_complete
File "/Users/ram/env/lib/python3.8/site-packages/aerich/cli.py", line 266, in init_db
await generate_schema_for_client(connection, safe)
File "/Users/ram/env/lib/python3.8/site-packages/tortoise/utils.py", line 29, in generate_schema_for_client
schema = get_schema_sql(client, safe)
File "/Users/ram/env/lib/python3.8/site-packages/tortoise/utils.py", line 18, in get_schema_sql
return generator.get_create_schema_sql(safe)
File "/Users/ram/env/lib/python3.8/site-packages/tortoise/backends/base/schema_generator.py", line 416, in get_create_schema_sql
tables_to_create.append(self._get_table_sql(model, safe))
File "/Users/ram/env/lib/python3.8/site-packages/tortoise/backends/base/schema_generator.py", line 202, in _get_table_sql
default = field_object.to_db_value(default, model)
File "/Users/ram/env/lib/python3.8/site-packages/tortoise/fields/data.py", line 322, in to_db_value
or (self.auto_now_add and getattr(instance, self.model_field_name) is None)
AttributeError: type object 'Cart' has no attribute 'created'
this is model
now it's throwing error for for created field