I’m writing a python project and using SQLModel. I have a class called District and it has 2 properties: id, name. The name is a string. The id is an md5 hash of the name. When I create an instance of a District like this District(name=”asdf”) how can I have SQLModel automatically set the id?
Is there a way to do this in the model definition?
You can use @field_validator from Pydantic (which SQLModel is built on top