Closed tufbel closed 2 years ago
I created a virtual field acronym and didn't want it to appear as a column in mysql :
acronym
class Company(models.Model): name = fields.CharField(max_length=32) acronym = fields.CharField(max_length=12, has_db_field=False) class PydanticMeta(object): allow_cycles = True max_recursion = 1 class Meta(object): table = f"{app_name}_company"
Use aerich after migration:
aerich migrate --name Company_acronym
-- upgrade -- ALTER TABLE `user_company` ADD `acronym` VARCHAR(12) NOT NULL; -- downgrade -- ALTER TABLE `user_company` DROP COLUMN `acronym`;
The has db field=False I set does not work
has db field=False
That's not the use case, has_db_field is used to custom field
has_db_field
I created a virtual field
acronym
and didn't want it to appear as a column in mysql :Use aerich after migration:
The
has db field=False
I set does not work