Skip to content

Can't Allow Extra Fields in SQLModel using Pydantic's extra="allow" option #1210

Closed Answered by LuckierDodge
LuckierDodge asked this question in Questions
Discussion options

You must be logged in to vote

Credit to brechin in the discord for pointing out the correct implementation:

from sqlmodel import SQLModel
from pydantic import ConfigDict

class Test(SQLModel):
    model_config = ConfigDict(extra="allow")

test = Test(a="a")
# Output: Test(a='a')
test.a
# Output: 'a'

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LuckierDodge
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
1 participant