Django Management Command ImportError

耗尽温柔 提交于 2019-12-04 10:34:00

Make sure that all the folders have a __init__.py in them so that they can be imported as modules. The structure is described here: https://docs.djangoproject.com/en/dev/howto/custom-management-commands/

Something like this for your structure:

qsl/
    __init__.py
    models.py
    management/
        __init__.py
        commands/
            __init__.py
            news.py
    jobs/
        __init__.py
        news.py
    tests.py
    views.py

If isn’t not a typo in file/directory structure then perhaps you are pip installing and having the issue?

In your setup.py under your packages=[] make sure you include

both qsl.management and qsl.management.commands. This solved the issue for me.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!