An FieldDoesNotExist happen when I use migrate

433 views
Skip to first unread message

Zhong Yang

unread,
May 19, 2015, 5:15:05 AM5/19/15
to django...@googlegroups.com
Hi everyone, I'm a new user, please help me if you have time, I'm very appreciate.
My Django version is 1.8.0
I have User model it has friends list which is many to many type, the code like this:
friends = models.ManyToManyField("self")
When I use command migrate to update database, the exception happened. The information showing like this:

Operations to perform:
  Synchronize unmigrated apps: staticfiles, rest_framework, messages, geoposition
  Apply all migrations: admin, normalUserFunctions, contenttypes, auth, sessions
Synchronizing apps without migrations:
  Creating tables...
    Running deferred SQL...
  Installing custom SQL...
Running migrations:
  Rendering model states... DONE
  Applying normalUserFunctions.0003_auto_20150519_0728...Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/migrate.py", line 221, in handle
    executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 110, in migrate
    self.apply_migration(states[migration], migration, fake=fake, fake_initial=fake_initial)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/executor.py", line 147, in apply_migration
    state = migration.apply(state, schema_editor)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/migration.py", line 115, in apply
    operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "/usr/local/lib/python2.7/dist-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 469, in alter_field
    return self._alter_many_to_many(model, old_field, new_field, strict)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/base/schema.py", line 785, in _alter_many_to_many
    old_field.rel.through._meta.get_field(old_field.m2m_field_name()),
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 554, in get_field
    raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name))
django.core.exceptions.FieldDoesNotExist: User_friends has no field named None

mohse...@gmail.com

unread,
Aug 3, 2015, 6:19:19 AM8/3/15
to Django users
Mr. Yang
Did you managed to solve this error?
Reply all
Reply to author
Forward
0 new messages