Django南不合逻辑的错误

时间:2014-01-31 17:00:02

标签: python django migration django-south

所以我在我的django项目中使用south,并且一直在改变一些模型逻辑。我改变了很多东西,但无论如何,我的模型看起来像现在

class Group(models.Model):
    '''table of organizational groups'''
    group_id = models.AutoField(primary_key=True)
    group_name = models.CharField(max_length=100,unique=True) #name of group as string
    icon_path_clicked = models.CharField(blank=True,max_length=255) #location icon is stored
    icon_path_unclicked = models.CharField(blank=True,max_length=255) #location icon is stored
    group_description = models.CharField(max_length=255) #description of the group
    is_active = models.BooleanField(default=True)
    date_created = models.DateTimeField(auto_now_add=True)

现在之前,icon_path_clickedicon_path_unclicked都有unique=True,但我把它拿出来了,但是当我尝试迁移时,我收到以下错误:

django.db.utils.IntegrityError: could not create unique index "everything_group_icon_path_clicked_key"
DETAIL:  Key (icon_path_clicked)=() is duplicated.

为什么它仍然会将此视为不再具有该字段?

完整追溯

Running migrations for app:
 - Migrating forwards to 0013_auto__chg_field_group_icon_path_clicked__chg_field_group_icon_path_unc.
 > everything:0007_auto__add_field_group_icon_path_clicked__add_field_group_icon_path_unc
FATAL ERROR - The following SQL query failed: ALTER TABLE "everything_group" ADD COLUMN "icon_path_clicked" varchar(255) NOT NULL UNIQUE DEFAULT '';
The error was: could not create unique index "everything_group_icon_path_clicked_key"
DETAIL:  Key (icon_path_clicked)=() is duplicated.

Error in migration: everything:0007_auto__add_field_group_icon_path_clicked__add_field_group_icon_path_unc
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/__init__.py", line 399, in execute_from_command_line
    utility.execute()
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/base.py", line 242, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/core/management/base.py", line 285, in execute
    output = self.handle(*args, **options)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/management/commands/migrate.py", line 111, in handle
    ignore_ghosts = ignore_ghosts,
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/__init__.py", line 220, in migrate_app
    success = migrator.migrate_many(target, workplan, database)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 230, in migrate_many
    result = migrator.__class__.migrate_many(migrator, target, migrations, database)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 305, in migrate_many
    result = self.migrate(migration, database)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 134, in migrate
    result = self.run(migration, database)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 115, in run
    return self.run_migration(migration, database)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 85, in run_migration
    migration_function()
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/migration/migrators.py", line 61, in <lambda>
    return (lambda: direction(orm))
  File "/Users/ryansaxe/Documents/project/app/migrations/0007_auto__add_field_group_icon_path_clicked__add_field_group_icon_path_unc.py", line 14, in forwards
    keep_default=False)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/db/generic.py", line 47, in _cache_clear
    return func(self, table, *args, **opts)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/db/generic.py", line 418, in add_column
    self.execute(sql)
  File "/Library/Python/2.7/site-packages/South-0.8.3-py2.7.egg/south/db/generic.py", line 282, in execute
    cursor.execute(sql, params)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/db/backends/util.py", line 69, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/db/utils.py", line 99, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Library/Python/2.7/site-packages/Django-1.6-py2.7.egg/django/db/backends/util.py", line 53, in execute
    return self.cursor.execute(sql, params)
django.db.utils.IntegrityError: could not create unique index "everything_group_icon_path_clicked_key"
DETAIL:  Key (icon_path_clicked)=() is duplicated.

0 个答案:

没有答案