Monday, August 3, 2015

Re: An FieldDoesNotExist happen when I use migrate

Mr. Yang
Did you managed to solve this error?

On Tuesday, May 19, 2015 at 1:45:05 PM UTC+4:30, Zhong Yang wrote:
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

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/97185920-6eb5-4c14-8647-be9eb2ee1f5b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment