4-21 启动main.py报错

来源:4-19 程序代码逻辑梳理

qq_森林的炎火_0

2018-03-20

/data/imoocc/apps/detail/models.py:7: RemovedInDjango19Warning: Model class detail.models.ConnectionInfo doesn't declare an explicit app_label and either isn't in an application in INSTALLED_APPS or else was imported before its application was loaded. This will no longer be supported in Django 1.9.

  class ConnectionInfo(models.Model):


Traceback (most recent call last):

  File "main.py", line 34, in <module>

    from apps.detail.utils.machines import Machines

  File "/data/imoocc/apps/detail/utils/machines.py", line 3, in <module>

    from detail.models import *

  File "/data/imoocc/apps/detail/models.py", line 7, in <module>

    class ConnectionInfo(models.Model):

  File "/root/.virtualenvs/imoocc/lib/python2.7/site-packages/django/db/models/base.py", line 309, in __new__

    new_class._meta.apps.register_model(new_class._meta.app_label, new_class)

  File "/root/.virtualenvs/imoocc/lib/python2.7/site-packages/django/apps/registry.py", line 221, in register_model

    (model_name, app_label, app_models[model_name], model))

RuntimeError: Conflicting 'connectioninfo' models in application 'detail': <class 'apps.detail.models.ConnectionInfo'> and <class 'detail.models.ConnectionInfo'>.


写回答

1回答

Jeson

2018-03-20

之前有同学和我反应过这个问题,但我本地没有出现,所以我觉得在django不同版本环境可以能会存在模块冲突 。

这样,将你本地的文件

/data/imoocc/apps/detail/utils/machines.py 中的第三行

from detail.models import *

修改为

from apps.detail.models import * 然后执行下,看看问题是否可以得到解决


0
1
qq_森林的炎火_0
非常感谢!
2018-03-21
共1条回复

Python+Django+Ansible Playbook自动化运维项目实战

【课程升级3.6版本】大牛全面践行DevOps,运维与开发间高效协作

861 学习 · 326 问题

查看课程