Skip to content
Discussion options

You must be logged in to vote

Hi guys, I just found another solution that worked on my side.

You can create a models package where you put all you model files like hero.py and team.py. In this package, use the __init__.py to import your public models and use model_rebuild() in it. Using this solution you'll no longer have to import and rebuild at the end of each file.

my_app
  | models 
  |   |  __init__.py  # import all your public models and rebuild the ones you need to
  |   |  hero.py
  |   |  team.py
  | main.py
# __init__.py

from my_app.models.hero import Hero, HeroCreate, HeroPublic, HeroPublicWithTeam, HeroUpdate
from my_app.models.team import Team, TeamCreate, TeamPublic, TeamPublicWithHeroes, TeamUpdate

H…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@charliejharrison
Comment options

Comment options

You must be logged in to vote
1 reply
@whugarra
Comment options

Comment options

You must be logged in to vote
3 replies
@carloshbcabral
Comment options

@davidwarshaw
Comment options

@ancelinSerre
Comment options

Answer selected by YuriiMotov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
7 participants