Django external library and app name conflict

不羁的心 提交于 2019-12-24 02:59:08

问题


Have a django app 'my_app'. Now added an external library that happens to have the same name and needs to be added to INSTALLED_APPS.

src
 |
 -- apps
      |
      --- **my_app**


external libraries
         |
          __ **my_app**
               |
                __some_path
                      |
                       __ new_module

Django follows the old path and spits out

Error: No module named my_app.some_path.new_module

because it is looking in the wrong folder.

INSTALLED_APPS = (
    ...
    apps.my_app
    my_app.some_path.new_module
    ...
)

Note: order of apps in INSTALLED_APPS makes no difference. Removing apps.my_app from INSTALLED_APS also made no difference.

When I try to type

import my_app

pycharm auto suggests apps.my_app

Is there any way to resolve this without renaming one of the apps?


回答1:


Well, brace yourself for the upcoming Django 1.7 release which solves such app conflicts in an elegant manner using an "app registry". You can set a label for each app to refer to them with a different name.



来源:https://stackoverflow.com/questions/21868958/django-external-library-and-app-name-conflict

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