Django 1.7迁移可以';找不到应用程序

Django 1.7迁移可以';找不到应用程序,django,django-migrations,Django,Django Migrations,运行迁移时,将字段从CharField更改为ManyToMany字段时出错 我有一个定制的用户模型来选择他们的兴趣,为了简单起见,我已经大大减少了这个模型 # main.models class Interest(models.Model): """ get what the user is interested in. """ name = models.CharField(max_length=30) def __str__(self):

运行迁移时,将字段从CharField更改为ManyToMany字段时出错

我有一个定制的用户模型来选择他们的兴趣,为了简单起见,我已经大大减少了这个模型

# main.models
class Interest(models.Model):
    """
    get what the user is interested in.
    """
    name = models.CharField(max_length=30)

    def __str__(self):
        return self.name


# accounts.models
from main.models import Interest

class User(AbstractUser):
    """
    the custom user class we are using
    """
    # before it was:
    # interests = models.CharField(max_length=100, blank=True)
    interests = models.ManyToManyField(Interest, blank=True, null=True,
        help_text="What are your interests or hobbies?")


# migration.py
from __future__ import unicode_literals

from django.db import models, migrations


class Migration(migrations.Migration):

    dependencies = [
        ('accounts', '0009_remove_user_friends'),
    ]

    operations = [
        migrations.AlterField(
            model_name='user',
            name='interests',
            field=models.ManyToManyField(help_text='What are your interests or hobbies?', to='main.Interest', null=True, blank=True),
            preserve_default=True,
        ),
    ]
主应用程序正确安装在
已安装的应用程序中,依赖项在那里,到目前为止我还没有遇到任何迁移问题(accounts应用程序中的第9次迁移)

这是堆栈跟踪。迁移文件中的
到class='main.Interest'
似乎有问题,但我不确定如何解决这个问题

Applying accounts.0010_auto_20150309_1554...Traceback (most recent call last):
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/apps/registry.py", line 148, in get_app_config
    return self.app_configs[app_label]
KeyError: 'main'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/db/migrations/state.py", line 84, in render
    model = self.apps.get_model(lookup_model[0], lookup_model[1])
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/apps/registry.py", line 202, in get_model
    return self.get_app_config(app_label).get_model(model_name.lower())
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/apps/registry.py", line 150, in get_app_config
    raise LookupError("No installed app with label '%s'." % app_label)
LookupError: No installed app with label 'main'.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 161, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/db/migrations/executor.py", line 68, in migrate
    self.apply_migration(migration, fake=fake)
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/db/migrations/executor.py", line 96, in apply_migration
    if self.detect_soft_applied(migration):
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/db/migrations/executor.py", line 140, in detect_soft_applied
    apps = project_state.render()
  File "/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/db/migrations/state.py", line 94, in render
    raise ValueError(msg.format(field=operations[0][1], model=lookup_model))
ValueError: Lookup failed for model referenced by field accounts.User.interests: main.Interest
应用帐户。0010\u自动\u 20150309\u 1554…回溯(最近一次呼叫):
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/apps/registry.py”,第148行,在get_app_config中
返回self.app\u配置[app\u标签]
KeyError:'main'
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/db/migrations/state.py”,第84行,在渲染中
model=self.apps.get\u model(查找模型[0],查找模型[1])
get_模型中的文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/apps/registry.py”,第202行
返回self.get\u app\u config(app\u标签)。get\u model(model\u name.lower())
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/apps/registry.py”,第150行,在get\u app\u config中
引发LookupError(“未安装标签为“%s”的应用程序”。%app\u标签)
LookupError:未安装标签为“main”的应用程序。
在处理上述异常期间,发生了另一个异常:
回溯(最近一次呼叫最后一次):
文件“/manage.py”,第10行,在
从命令行(sys.argv)执行命令
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/core/management/__init__.py”,第385行,从命令行执行
utility.execute()
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/core/management/__init__.py”,执行中第377行
self.fetch_命令(子命令)。从_argv(self.argv)运行_
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site-packages/django/core/management/base.py”,第288行,运行时从
self.execute(*args,**选项._dict__;
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/core/management/base.py”,第338行,在execute中
输出=self.handle(*args,**选项)
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/core/management/commands/migrate.py”,第161行,在handle中
executor.migrate(目标、计划、假=options.get(“假”,假))
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/db/migrations/executor.py”,第68行,在migrate中
self.apply\u迁移(迁移,假=假)
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/db/migrations/executor.py”,第96行,在应用程序迁移中
如果应用了自检测软件(迁移):
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/db/migrations/executor.py”,第140行,在detect\u soft\u应用
apps=project\u state.render()
文件“/Users/awwester/Sites/django/rlg/lib/python3.4/site packages/django/db/migrations/state.py”,第94行,呈现
raise VALUERROR(消息格式(字段=操作[0][1],模型=查找\模型))
ValueError:字段accounts引用的模型的查找失败。用户。兴趣:主要。兴趣

用户类是模型的一个子类吗?不,直接来自django.contrib.auth.models.AbstractUserFrom django的参考:在处理与自定义用户模型中的身份验证不直接相关的信息之前,请仔细考虑。最好将特定于应用程序的用户信息存储在与用户模型有关系的模型中。这样,每个应用程序都可以指定自己的用户数据要求,而不会与其他应用程序发生冲突。另一方面,检索此相关信息的查询将涉及数据库联接,这可能会对性能产生影响