Django"对未知应用程序的依赖"即使app文件夹存在,也会出错

时间:2015-03-22 06:02:10

标签: python django

我尝试运行manage.py runserver或manage.py makemigrations,但是当我这样做时,我收到了错误。错误是:ValueError:对未知应用程序的依赖:后端。

这里是完整的错误消息:

Benjamins-MacBook-Pro:package-backend benhsu$ python3 manage.py makemigrations
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/core/management/commands/makemigrations.py", line 57, in handle
    loader = MigrationLoader(None, ignore_no_migrations=True)
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/loader.py", line 48, in __init__
    self.build_graph()
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/loader.py", line 243, in build_graph
    parent = self.check_key(parent, key[0])
  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/db/migrations/loader.py", line 168, in check_key
    raise ValueError("Dependency on unknown app: %s" % key[0])
ValueError: Dependency on unknown app: backend

&#34;后端&#34;是我正在处理的应用,您可以在我的文件夹中看到它存在。这是我的文件夹结构:

enter image description here

这是我的settings.py文件的相关部分:

# Application definition

AUTH_USER_MODEL = 'backend.User'

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'backend'
)

我不明白为什么它不能正常工作,因为后端应用程序存在于我的文件夹中。

我很感激任何帮助!

2 个答案:

答案 0 :(得分:2)

custom User以来,您是否尝试使用AUTH_USER_MODEL = 'backend.User'模型?

所以你必须尝试这样。

 ./manage.py makemigrations backend

来自https://docs.djangoproject.com/en/1.7/topics/migrations/#s-custom-fields

答案 1 :(得分:0)

我使用自定义user应用程序遇到了同样的错误。

我删除了:

  • 所有migrations个文件夹
  • 所有*.pyc个文件
  • 所有__pycach__目录
  • my sql lite db
然后我跑了

python manage.py syncdb

这就是诀窍