0

How do I import certain models from one project in one directory, into another project in another directory? Both projects share the same database.

My directory structure is like this:

root
    directory1
        project1
        app1_of_project1
            models.py
        ...
        manage.py
    directory2
        project2
        app1_of_project2
            models.py
        ...
        manage.py

App1_of_project2 needs some models from app1_of_project1.

I tried this answer, but I get:

RuntimeError: Model class app1_of_project1.models.Model1 doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

INSTALLED_APPS of project1 has app1_of_project1 included, and INSTALLED_APPS of project2 has app1_of_project2 included.

This answer gives me a ModuleNotFoundError.

I cannot merge the two projects and make them separate apps within one project.

Also, I do not want to move the project directory to PYTHON_PATH.

Can anyone suggest a workaround?

Thanks!

codeandfire
  • 445
  • 2
  • 9

0 Answers0