-1

directory structure

  project
     __init__.py
     subproject1
          __init__.py
          app1
             __init__.py
             urls.py
             views.py
             models.py
          app2
             __init__.py
             urls.py
             views.py
             models.py
          settings.py
          urls.py
          manage.py
          redis.py
      subproject2
         __init__.py
         a.py
         b.py
         c.py

i want to use settings.py and some functions return in redis.py of subproject1 inside b.py of subproject2. Is it possible? If yes how?

gourav kumar
  • 141
  • 1
  • 11
  • 1
    Possible duplicate of [Importing files from different folder](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) – Brown Bear Mar 05 '19 at 12:26
  • add `__init__.py` to `subproject2` and to `project` also then import them – A.Raouf Mar 05 '19 at 12:27
  • 3
    You never reference your settings file directly in django, you need to import from `django.conf` and also include what you've tried. – Sayse Mar 05 '19 at 12:49
  • i added __init_.py to each directory and wrote inside subproject2 import settings inside b.py but got error ImportError: No module named subproject2 – gourav kumar Mar 05 '19 at 12:54
  • This is nothing Django-specific, just plain python module search path: https://docs.python.org/3/tutorial/modules.html#the-module-search-path – bruno desthuilliers Mar 05 '19 at 13:36

1 Answers1

0

You must have to modify all directory to python package directory. you can do it easily with adding of __init__.py inside all directory.

Sonu
  • 106
  • 3