Well, as the title says I'm constantly getting the above error when trying to import a class from another app.
My file structure looks like this (I am on openshift btw):
- openshiftappname
- .openshift
- data
- libs
- wsgi
- myproject
- myproject
- app1
models.py (file with class to import)
- app2
forms.py (file with import)
manage.py
- static
__init__.py
application
setup.py
My import looks like this:
from wsgi.myproject.app1.models import PrivateClient
I've also tried:
from ..app1.models import PrivateClient
from ..app1 import PrivateClient
but both these statements give me the error: "ValueError at / attempted relative import beyond top-level package"
contents of wsgi/myproject/myproject/wsgi.py:
import os
from django.core.wsgi import get_wsgi_application
# GETTING-STARTED: change 'myproject' to your project name:
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
application = get_wsgi_application()
Note that both apps are added to the installed_apps in the settings file
What should I do? I have no clue why I'm getting this error and I was unable to find a solution on the web after extensive searching. Thanks in advance!
Just use what @ahmed-hosny mentioned in comments:
from app1.models import PrivateClient
Please always reply to comments, answer your question (if nobody else did) and mark it as answered. Thanks.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.