开发者社区> 问答> 正文

Django1.7 syncdb报错?报错

H:\dev\AppServ\www\PythonProjects\DjangoTest>python manage.py syncdb
Operations to perform:
  Apply all migrations: admin, contenttypes, auth, sessions
Running migrations:
  Applying contenttypes.0001_initial... OK
  Applying auth.0001_initial... OK
  Applying admin.0001_initial... OK
  Applying sessions.0001_initial... OK
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\__init__.py",
line 385, in execute_from_command_line
    utility.execute()
  File "H:\dev\python2.7\lib\site-packages\django\core\management\__init__.py",
line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\base.py", line
 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\base.py", line
 338, in execute
    output = self.handle(*args, **options)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\base.py", line
 533, in handle
    return self.handle_noargs(**options)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\commands\syncd
b.py", line 27, in handle_noargs
    call_command("migrate", **options)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\__init__.py",
line 115, in call_command
    return klass.execute(*args, **defaults)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\base.py", line
 338, in execute
    output = self.handle(*args, **options)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\commands\migra
te.py", line 164, in handle
    emit_post_migrate_signal(created_models, self.verbosity, self.interactive, c
onnection.alias)
  File "H:\dev\python2.7\lib\site-packages\django\core\management\sql.py", line
268, in emit_post_migrate_signal
    using=db)
  File "H:\dev\python2.7\lib\site-packages\django\dispatch\dispatcher.py", line
198, in send
    response = receiver(signal=self, sender=sender, **named)
  File "H:\dev\python2.7\lib\site-packages\django\contrib\contenttypes\managemen
t.py", line 56, in update_contenttypes
    ContentType.objects.using(using).bulk_create(cts)
  File "H:\dev\python2.7\lib\site-packages\django\db\models\query.py", line 409,
 in bulk_create
    self._batched_insert(objs_without_pk, fields, batch_size)
  File "H:\dev\python2.7\lib\site-packages\django\db\models\query.py", line 938,
 in _batched_insert
    using=self.db)
  File "H:\dev\python2.7\lib\site-packages\django\db\models\manager.py", line 92
, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "H:\dev\python2.7\lib\site-packages\django\db\models\query.py", line 921,
 in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "H:\dev\python2.7\lib\site-packages\django\db\models\sql\compiler.py", li
ne 920, in execute_sql
    cursor.execute(sql, params)
  File "H:\dev\python2.7\lib\site-packages\django\db\backends\utils.py", line 81
, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "H:\dev\python2.7\lib\site-packages\django\db\backends\utils.py", line 65
, in execute
    return self.cursor.execute(sql, params)
  File "H:\dev\python2.7\lib\site-packages\django\db\utils.py", line 94, in __ex
it__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "H:\dev\python2.7\lib\site-packages\django\db\backends\utils.py", line 65
, in execute
    return self.cursor.execute(sql, params)
  File "H:\dev\python2.7\lib\site-packages\django\db\backends\mysql\base.py", li
ne 128, in execute
    return self.cursor.execute(query, args)
  File "H:\dev\python2.7\lib\site-packages\MySQLdb\cursors.py", line 205, in exe
cute
    self.errorhandler(self, exc, value)
  File "H:\dev\python2.7\lib\site-packages\MySQLdb\connections.py", line 36, in
defaulterrorhandler
    raise errorclass, errorvalue
django.db.utils.IntegrityError: (1062, "Duplicate entry 'auth-group' for key 'dj
ango_content_type_app_label_3ec8c61c_uniq'")

数据库都是空的,怎么就违反唯一键约束了呢?



展开
收起
爱吃鱼的程序员 2020-06-14 20:17:47 575 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    1.7好像没syncdb这个命令了吧。请问这个问题解决了吗??

    2020-06-14 20:18:02
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
低代码开发师(初级)实战教程 立即下载
冬季实战营第三期:MySQL数据库进阶实战 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载