django.db.utils.ProgrammingError:relation" locations_location"迁移期间不存在

时间:2017-04-05 13:51:42

标签: django

我为我的项目创建了一个自定义应用程序,位置。我不知道是什么,但是在设置过程中出现了一些问题。我删除了所有迁移并删除了此应用程序的数据库中的所有内容以重新启动,并且在创建表后尝试执行初始迁移时仍然出现错误。我的模特有问题吗?我不明白这个错误。

class Staff(models.Model):
    first_name = models.CharField(max_length=255)
    last_name = models.CharField(max_length=255)
    about = models.CharField(max_length=255)

class Map(models.Model):
    image = models.ImageField()

class Location(models.Model):
    name = models.CharField(max_length=255)
    phone = models.CharField(max_length=20, verbose_name="Phone Number")
    email = models.CharField(max_length=255, verbose_name="Email Address")
    # manager = models.ForeignKey(Staff,related_name='+')
    staff = models.ManyToManyField(Staff)
    map = models.ForeignKey(Map, null=True)

堆栈追踪:

Applying locations.0013_auto_20170405_0934...Traceback (most recent call last):
  File "build//clientname/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
  File "build/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
  File "build/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "build/env/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
  File "build/env/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
  File "build/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
  File "build/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
  File "build/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
  File "build/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration
state = migration.apply(state, schema_editor)
  File "build/env/lib/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
  File "build/env/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 121, in database_forwards
schema_editor.remove_field(from_model, from_model._meta.get_field(self.name))
  File "build/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 438, in remove_field
self.execute(sql)
  File "build/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute
cursor.execute(sql, params)
  File "build/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
  File "build/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
  File "build/env/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "build/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)

django.db.utils.ProgrammingError:relation&#34; locations_location&#34;不存在

0 个答案:

没有答案