Skip to content

Does ormar have ormar-only fields? #389

Answered by collerek
sondrelg asked this question in Q&A
Discussion options

You must be logged in to vote

There is no such thing as of now (btw. you cannot exclude primary keys).
If you set your fields to be populated in the database (like on update current timestamp), as I believe this is your use case, you can work around this by not including the fields in the model altogether.

If you manage migrations with ormar and you need this column in the structure, then you can hack around this by also not including the fields in ormar, but adding those fields into the underlying sqlalchemy table (which is stored in Model.Meta.table), but note that this requires sqlalchemy core notation, not the orm one, so something like:

column = sqlalchemy.Column(name, column_type, constraints etc.)
model.Meta.table

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sondrelg
Comment options

Answer selected by sondrelg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants