The following is the project directory structure I built under the project. Apps contains all the applications.
So I added the package guide path of the project below to facilitate the package guide.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) sys.path.insert(0, os.path.join(BASE_DIR, 'apps')) sys.path.insert(0, os.path.join(BASE_DIR, 'extra_apps'))
After investigation, it was found that the reason for this error was because the code was written like this when I imported the package:
from apps.users.models import BaseModel
from apps.courses.models import Course
So after I removed the apps, there was no error:
from users.models import BaseModel
from courses.models import Course
Summary: I personally think that the reason for this error is that we have added these two guide package paths. Every time the project guides the package, it will start from these guide package paths, and then start to find it. The first thing is to find the apps folder under these guide package paths. It is not found, so it starts to report such an error.
- How to Solve Python SyntaxError: EOL while scanning string literal
- django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named ‘M…
- Django auth.User.groups: (fields.E304) Reverse accessor for User.groups clashes with reverse
- ModuleNotFoundError: No module named ‘utils’ [How to Solve]
- [Solved] PyCharm Start Error: TypeError: unsupported operand type(s) for /: ‘str’ and ‘str’
- Django Run Error: RuntimeError: maximum recursion depth exceeded while calling a Python object
- ERRORS: ?: (corsheaders.E013) Origin ‘*’ in CORS_ORIGIN_WHITELIST is missing scheme or ne…
- This application failed to start because not Qt platform plugin could be initialized.
- python Warning: OverflowError: Python int too large to convert to C long
- Vue production webpack package PathError [Solved]