Replies: 2 comments
-
Also, do you have to redefine Meta in EVERY class definition? I was hoping to extend the Base class and have the database etc be inherited |
Beta Was this translation helpful? Give feedback.
-
Hi @yudjinn Your Code was a bit messy and I couldn't read it well, but if you like it, I have a project in this link where you can look at how to define models and inheritance and their relationship with each other. I hope it will be useful and useful to you. |
Beta Was this translation helpful? Give feedback.
-
I have the following setup:
models
├─base.py
├─user.py
└─item.py
Base is defined as such:
`
class BaseMeta(ormar.ModelMeta):
database = database
metadata = metadata
class Base(ormar.Model, DateFieldsMixins):
class Meta(BaseMeta):
abstract = True
User:
class User(Base):class Meta:
abstract = True
tablename = "users"
class UserDB(User):
hashed_password: str = ormar.String(max_length=256)
and Item:
class Item(Base):
class Meta:
tablename = "items"
`
when running
alembic revision --autogenerate -m "init"
I get:AttributeError: type object 'Meta' has no attribute 'pkname' from ormar/fields/foreign_key.py:114
I'm guessing the UUID column does not set the primary key attribute on the meta class? The docs didnt seem to answer how to handle mutli-file models so I may have missed something.
Beta Was this translation helpful? Give feedback.
All reactions