You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class MeasureUnit(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=200)
abbreviation = fields.CharField(max_length=200)
class Meta:
table_name = "measure_units"
class ProductMeasureUnit(Model):
product = fields.ForeignKeyField(
'models.Product',
on_delete=fields.CASCADE
)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello dear developers, I am newbie to Tortoise and Django-like orm systems. I faced bug which I don't know how to fix
Here is my models:
from tortoise import fields
from tortoise.models import Model
class Product(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=500)
description = fields.TextField(null=True)
price_per_unit = fields.FloatField()
purchase_price = fields.FloatField()
retail_price = fields.FloatField()
whole_sail_price = fields.FloatField()
rating = fields.FloatField(null=True)
shelf_life = fields.FloatField(null=True)
units_amount = fields.IntField(null=True)
creation_date = fields.DatetimeField(auto_now_add=True)
last_edit_date = fields.DatetimeField(auto_now=True)
last_edit_user_id = fields.ForeignKeyField("models.User", on_delete=fields.SET_NULL, null=True)
class MeasureUnit(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=200)
abbreviation = fields.CharField(max_length=200)
class ProductMeasureUnit(Model):
product = fields.ForeignKeyField(
'models.Product',
on_delete=fields.CASCADE
)
class Characteristic(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=500)
description = fields.TextField(null=True)
class ProductCharacteristic(Model):
product = fields.ForeignKeyField(
"models.Product",
related_name="product_characteristics",
on_delete=fields.CASCADE
)
class ProductCategory(Model):
id = fields.IntField(primary_key=True)
name = fields.CharField(max_length=255, unique=True)
description = fields.TextField(null=True, blank=True)
parent = fields.ForeignKeyField(
"models.ProductCategory",
related_name="subcategories",
null=True,
blank=True,
on_delete=fields.SET_NULL
)
class AssignedProductCategory(Model):
product = fields.ForeignKeyField(
"models.Product",
on_delete=fields.CASCADE
)
category = fields.ForeignKeyField(
"models.ProductCategory",
on_delete=fields.CASCADE
)
class Document(Model):
id = fields.IntField(primary_key=True)
file_path = fields.TextField()
I have through tables for product, but when I make a migration using aerich I see in pgAdmin duplicates of tables
And also maybe because of that I can't retreive corresponding submodels from model product
Beta Was this translation helpful? Give feedback.
All reactions