Reputation: 415
I want to import some functions a constants variables from 5 levels upper of the current app of Django application.
My problem is that the package that I want to import from, is outside of the Django application, so Django isn't aware of it.
project structure:
├── lawcrawler
│ ├── get_all_amended_laws_urls.py # import a function from this file
│ ├── lawcrawler
│ │ └── spiders
│ │ └── settings.py # import variables from this file
│ │
├── project
│ ├── apps
│ │ ├── laws
│ │ ├── management
│ │ ├── commands
│ │ ├── add_list_of_amended_laws.py # import function and variables to this file
│ ├── manage.py
As per python docs, two or more leading dots indicate a relative import to the parent(s) of the current package, one level per dot after the first. So, I tried relative import like this:
from .......lawcrawler.lawcrawler.spiders.settings import SPARQL_ENDPOINT, AMENDED_URL_FILE_PATH, get_law_amendment_query
and this:
from .....lawcrawler import get_all_amended_urls
but got this error:
ImportError: attempted relative import with no known parent package
How to import the functions and variables or solve this issue?
Upvotes: 0
Views: 124