Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circular imports #57

Closed
aminalaee opened this issue Feb 17, 2017 · 2 comments
Closed

Circular imports #57

aminalaee opened this issue Feb 17, 2017 · 2 comments

Comments

@aminalaee
Copy link

I have a Flask app that has a structure like the following:

project
  -- users
    __init__.py
    models.py
    views.py
    serializers.py
  -- genres
    __init__.py
    models.py
    views.py
    serializers.py

I have a ModelSchema class in one of my folders that uses models.py from the other folder. SQLAlchemy by default solves this problem by using the string name of the class but I get circular import errors in Marshmallow SQLAlchemy. Is there a way to solve this? Or shoud I change my structure?

@Msiavashi
Copy link

i have the same problem and its really bothering . does anyone know how to solve this ?

@sloria
Copy link
Member

sloria commented Jul 30, 2019

See #143; the solution is to keep the schemas in a separate module from models and ensure that models are all initialized before schemas are initialized.

This needs to be documented better, as suggested on the linked issue.

@sloria sloria closed this as completed Jul 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants