tortoise / tortoise/tortoise-orm

Base class fields of Model are None

Open
#1,144 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Describe the bug
I've created models like in this tutorial https://tortoise-orm.readthedocs.io/en/latest/models.html#inheritance and trying retrieve object of child class (from example it's UserModel) but fields 'created_at' and 'modified_at' from TimestampMixin are None. But I can see in database fields are filled, so the problem is in retrieving fields for base Model.

To Reproduce
https://tortoise-orm.readthedocs.io/en/latest/models.html#inheritance

Expected behavior
I want to isolate some repetitive fields in separate Class not inherited from models.Model and be able to get them.

Additional context
Python - 3.10.0
Tortoise ORM - 0.19.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the inheritance example in the linked models tutorial and reproduce the issue using the reported Python 3.10.0 and Tortoise ORM 0.19.1 versions. Trace how fields from TimestampMixin are loaded when retrieving the child model; done means created_at and modified_at are populated instead of None.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.