【已解决!】ImportError: cannot import name ‘ProjectModelSerializer‘ from partially initialized module ‘pr

question:

When running Django, an exception occurred, and the console output exception is:

ImportError: cannot import name 'ProjectModelSerializer' from partially initialized module 'projects.serializers' (most likely due to a circular import) (/Users/。。/。。/。。/projects/serializers.py)

solve:

Reason: It turned out that there were mutual references in two files.

In the projects.serializers.py file:

from interfaces.serializers import InterfaceModelSerializer

In the interfaces.serializers.py file:

from projects.serializers import ProjectModelSerializer

When I commented out one of the references, things went back to normal

Guess you like

Origin blog.csdn.net/weixin_43569834/article/details/131456635