I'm using Fastapi, Fastapi Users and TortoiseOrm for auth on my project.
I followed the example on FastApi Users website and when I try to add some extra fields at register users, get this error:
RuntimeError: no validator found for <class 'tortoise.fields.data.CharField'>, see arbitrary_types_allowed in Config
Here is my code, thanks for your help!
from tortoise import fields
from tortoise.contrib.pydantic import pydantic_model_creator
from fastapi_users import models
from fastapi_users.db import TortoiseBaseUserModel, TortoiseUserDatabase
from tortoise.contrib.starlette import register_tortoise
class User(models.BaseUser):
nombre = fields.CharField(max_length=100)
apellidos = fields.CharField(max_length=100)
class UserCreate(models.BaseUserCreate):
pass
class UserUpdate(User, models.BaseUserUpdate):
pass
class UserDB(User, models.BaseUserDB):
pass
class UserModel(TortoiseBaseUserModel):
pass
user_db = TortoiseUserDatabase(UserDB, UserModel)
This worked for me, it requires the tortoise ORM format for the field: