Python django shell未检测到新模块

Python django shell未检测到新模块,python,django,python-3.x,django-shell,Python,Django,Python 3.x,Django Shell,您好,我有一个django应用程序名“celery_tasks”,具有以下目录结构: . ├── apps.py ├── emitter ├── __init__.py ├── kse ├── mongo 我添加了一个新模块名kse,其中包含两个文件: ├── __init__.py ├── lol.py kse模块中的\uuuu init\uuuuu.py包含from.lol导入lol 并且lol.py文件包含以下类: class lol: @staticmethod d

您好,我有一个django应用程序名“celery_tasks”,具有以下目录结构:

.
├── apps.py
├── emitter
├── __init__.py
├── kse
├── mongo
我添加了一个新模块名kse,其中包含两个文件:

├── __init__.py
├── lol.py
kse模块中的
\uuuu init\uuuuu.py
包含
from.lol导入lol

并且lol.py文件包含以下类:

class lol:

    @staticmethod
    def x():
        return True

    def __init__(self):
        pass
问题是我无法通过django shell访问
kse
模块:

>>> import celery_tasks
>>> celery_tasks.kse
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: module 'celery_tasks' has no attribute 'kse'

要以您期望的方式导入模块,您应该导入
kse
inside
cellery\u tasks/\uuuu init\uuuuuuy.py

您能在目录中发布一个“ls-la”输出吗?我想您对导入的工作方式感到困惑。导入一个包不会让您访问子包;您需要直接导入这些(
从芹菜任务导入kse
)。我没有在
\uu init\uuuuuuuuuuuuuuuy.py
中从芹菜任务导入mongo,但我可以通过
导入芹菜任务访问mongo;芹菜任务。mongo
。只有kse模块不工作。导入
kse
内部
celery\u任务/\uuuu init\uuuuu.py
会导致Django错误:
raise AppRegistryNotReady(“应用程序尚未加载”)
确定,解决了错误,错误地导入了模块。谢谢
>>> celery_tasks.mongo
<module 'celery_tasks.mongo' from '/Users/kheshav/Linux_projects/rockynode.io/App/rockynode/celery_tasks/mongo/__init__.py'>
>>> celery_tasks.emitter
<module 'celery_tasks.emitter' from '/Users/kheshav/Linux_projects/rockynode.io/App/rockynode/celery_tasks/emitter/__init__.py'>
drwxr-xr-x 11 root root  374 Oct 13 19:28 .
drwxr-xr-x 14 root root  476 Oct 12 22:51 ..
-rw-r--r--  1 root root   98 Dec 11  2016 apps.py
drwxr-xr-x  5 root root  170 Oct 12 19:56 emitter
-rw-r--r--  1 root root    0 Oct 13 20:51 __init__.py
drwxr-xr-x  5 root root  170 Oct 13 19:53 kse
drwxr-xr-x  6 root root  204 Oct 12 19:56 mongo
drwxr-xr-x  3 root root  102 Oct 13 20:50 __pycache__
drwxr-xr-x  5 root root  170 Oct 12 22:51 zabbix