Django 1.8迁移-"NoneType"对象没有属性"_meta"; [英] Django 1.8 Migrations - "NoneType" object has no attribute "_meta"

查看:36
本文介绍了Django 1.8迁移-"NoneType"对象没有属性"_meta";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试将项目从Django 1.7迁移到1.8.在解决了代码错误之后,我能够运行迁移.但是,当我尝试迁移时,出现错误'NoneType'对象没有属性'_meta'"

Attempting to migrate a project from Django 1.7 to 1.8. After wrestling with code errors, I'm able to get migrations to run. However, when I try to migrate, I'm given the error "'NoneType' object has no attribute '_meta'"

在回溯中没有任何我的应用程序的引用,因此我不确定寻找错误的确切位置(以及此处包含的代码,因此对于那些试图帮助您的人会有所帮助我)

There's no reference in the traceback to any of my apps, so I'm unsure of where exactly to go about looking for the bug (as well as which code to include here so I can be more helpful to those trying to help me)

这是追溯的全文

(venv)rtownley@ubuntu:~/Projects/sparrow1/NJ$ ./manage.py makemigrations
No changes detected
(venv)rtownley@ubuntu:~/Projects/sparrow1/NJ$ ./manage.py migrate
Operations to perform:
  Synchronize unmigrated apps: staticfiles, editor, djcelery, messages, getty, kombu_transport_django, debug_toolbar, utils, locking, petro, tokenapi, grappelli, django_extensions, selectable
  Apply all migrations: adops, taxonomy, issues, editorial, contenttypes, authors, auth, comms, membership, sessions, bento, urlalias, accounts, breaking_news, easy_thumbnails, images, admin, pages, documents, events
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states...Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/db/migrations/executor.py", line 104, in migrate
    state = migration.mutate_state(state, preserve=do_run)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/db/migrations/migration.py", line 83, in mutate_state
    operation.state_forwards(self.app_label, new_state)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/db/migrations/operations/fields.py", line 51, in state_forwards
    state.reload_model(app_label, self.model_name_lower)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/db/migrations/state.py", line 97, in reload_model
    related_models = get_related_models_recursive(old_model)
  File "/home/rtownley/Projects/sparrow1/venv/lib/python3.4/site-packages/django/db/migrations/state.py", line 57, in get_related_models_recursive
    rel_app_label, rel_model_name = rel_mod._meta.app_label, rel_mod._meta.model_name
AttributeError: 'NoneType' object has no attribute '_meta'

其他可能发挥作用的作品:-我有一个自定义处理程序,用于监听save事件,序列化数据并在Mongo中创建相同的对象-在运行Python3.4的虚拟环境中运行

Other pieces that could potentially be at play: -I have a custom handler that listens for the save event, serializes the data, and creates an identical object in Mongo -Operating out of a virtual environment running Python3.4

关于如何寻找错误的任何想法?谢谢,抱歉,我无法提供更多代码!

Any thoughts on where to go about hunting for the error? Thanks, and sorry I can't provide more code yet!

推荐答案

感谢meiamsome,我弄清楚了:我的一个模型与一个不存在的模型建立了ForeignKey关系(我删除了它,并添加了一个Git合并已将其添加回去).谢谢大家的帮助!

Thanks to meiamsome, I figured it out: one of my models had a ForeignKey relationship to a model that no longer existed (I had removed it, and a Git merge had added it back). Thanks for the help all!

这篇关于Django 1.8迁移-"NoneType"对象没有属性"_meta";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆