Open lokichaulagain opened 1 year ago
Which post endpoint causes this error?
Which post endpoint causes this error?
Sale post method
Did you solved this problem? I'm running into this issue as well
https://tortoise.github.io/models.html#foreignkeyfield I got it
from typing import Optional
from pydantic import BaseModel
from models.Table import Table
class SaleIn(BaseModel):
discount_amount: float
is_draft: bool
table_id: int # foreignkeyfield will append `_id` in database
I m using fastapi , tortoise-orm and pydantic , everything works fine except the Post method which contain foreign key field. I get the error saying AttributeError: 'int' object has no attribute '_saved_in_db' for database I am using elephantSql(postgres) Repo : https://github.com/lokendra-chaulagain/object-has-no-attribute-in-db-issue
Table model
Sale Model
Table Schema
Sale Schema
Sale Route (Controller)
Error: