mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-05 15:37:54 +08:00
Tortoise ORM support (#59)
* add tortoise to dependencies * add tortoise as optional dependency in pyproject.toml * add tortoise support (tests needed) * Add tortoise support (also defined orm_mode in pydantic model * tests for tortoise support * format by black * docs for tortoise * delete type annotations * delete underscore * do it in 1 line * add 1 line before yield * fix in docs * fix bug and add annotation for test * Tweak documentation and fix Tortoise error about id update * Improve Tortoise coverage by using get instead of filter * Fix Pipfile.lock
This commit is contained in:
committed by
François Voron
parent
358150bbff
commit
b5b0bbbb01
16
docs/src/db_tortoise.py
Normal file
16
docs/src/db_tortoise.py
Normal file
@ -0,0 +1,16 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi_users.db.tortoise import BaseUserModel, TortoiseUserDatabase
|
||||
from tortoise import Model
|
||||
from tortoise.contrib.starlette import register_tortoise
|
||||
|
||||
DATABASE_URL = "sqlite://./test.db"
|
||||
|
||||
|
||||
class UserModel(BaseUserModel, Model):
|
||||
pass
|
||||
|
||||
|
||||
user_db = TortoiseUserDatabase(UserModel)
|
||||
app = FastAPI()
|
||||
|
||||
register_tortoise(app, modules={"models": ["path_to_your_package"]})
|
||||
Reference in New Issue
Block a user