import model class from another app

django version : 3.1.4

and i want to use classes in models in A app. so i choose to use <from …member.models import User> and it show some errors. <from …member.models import User, ImportError: attempted relative import beyond top-level package>. so how can i import models from another app??? matters between approval app and member app.

my github link : https://github.com/yejun1060/approval

Your “current directory” for a django project is not the directory in which your models.py resides. You should be able to just do from member.models import User

1 Like

wow !! i resolve this problem ! thank you ~

I have similar problem. I’m trying to import model from app A to inner package of app B, could you help me please?

To clarify this - your “current directory” for imports in Django is your base directory. All imports are done relative to it - not whatever directory your code being executed currently resides in. It doesn’t matter where that import statement is located.

Allready solved my problem, thanks for answering:)