创建超级用户后 django manage.pysyncdb 失败

发布于 2024-12-28 14:36:54 字数 4389 浏览 0 评论 0原文

djnago1.3.1 python2.7.2+ ubuntu 11.10 我正在制作syncdb,创建超级用户后我得到了这个错误:

 You just installed Django's auth system, which means you don't have any superusers defined.
    Would you like to create one now? (yes/no): yes
    Username (Leave blank to use 'root'): antonio
    E-mail address: [email protected]
    Password: 
    Password (again): 
    Superuser created successfully.
    Traceback (most recent call last):
      File "manage.py", line 14, in <module>
        execute_manager(settings)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, 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 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
        emit_post_sync_signal(created_models, verbosity, interactive, db)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
        interactive=interactive, db=db)
      File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 172, in send
        response = receiver(signal=self, sender=sender, **named)
      File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 30, in create_permissions
        ctype = ContentType.objects.get_for_model(klass)
      File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py", line 38, in get_for_model
        defaults = {'name': smart_unicode(opts.verbose_name_raw)},
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 135, in get_or_create
        return self.get_query_set().get_or_create(**kwargs)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 385, in get_or_create
        obj.save(force_insert=True, using=self.db)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 460, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 553, in save_base
        result = manager._insert(values, return_id=update_pk, using=using)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 195, in _insert
        return insert_query(self.model, values, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1436, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
        cursor = super(SQLInsertCompiler, self).execute_sql(None)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
        cursor.execute(sql, params)
      File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 86, in execute
        return self.cursor.execute(query, args)
      File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 176, in execute
        if not self._defer_warnings: self._warning_check()
      File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 92, in _warning_check
        warn(w[-1], self.Warning, 3)
    _mysql_exceptions.Warning: Incorrect string value: '\xD0\xA0\xD0\xB5\xD0\xB3...' for column 'name' at row 1

请帮助=)

djnago1.3.1 python2.7.2+ ubuntu 11.10
I am making syncdb, after creating superuser I've got that error:

 You just installed Django's auth system, which means you don't have any superusers defined.
    Would you like to create one now? (yes/no): yes
    Username (Leave blank to use 'root'): antonio
    E-mail address: [email protected]
    Password: 
    Password (again): 
    Superuser created successfully.
    Traceback (most recent call last):
      File "manage.py", line 14, in <module>
        execute_manager(settings)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 438, in execute_manager
        utility.execute()
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 379, 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 191, in run_from_argv
        self.execute(*args, **options.__dict__)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 220, in execute
        output = self.handle(*args, **options)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 351, in handle
        return self.handle_noargs(**options)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/syncdb.py", line 109, in handle_noargs
        emit_post_sync_signal(created_models, verbosity, interactive, db)
      File "/usr/local/lib/python2.7/dist-packages/django/core/management/sql.py", line 190, in emit_post_sync_signal
        interactive=interactive, db=db)
      File "/usr/local/lib/python2.7/dist-packages/django/dispatch/dispatcher.py", line 172, in send
        response = receiver(signal=self, sender=sender, **named)
      File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/management/__init__.py", line 30, in create_permissions
        ctype = ContentType.objects.get_for_model(klass)
      File "/usr/local/lib/python2.7/dist-packages/django/contrib/contenttypes/models.py", line 38, in get_for_model
        defaults = {'name': smart_unicode(opts.verbose_name_raw)},
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 135, in get_or_create
        return self.get_query_set().get_or_create(**kwargs)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 385, in get_or_create
        obj.save(force_insert=True, using=self.db)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 460, in save
        self.save_base(using=using, force_insert=force_insert, force_update=force_update)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 553, in save_base
        result = manager._insert(values, return_id=update_pk, using=using)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py", line 195, in _insert
        return insert_query(self.model, values, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 1436, in insert_query
        return query.get_compiler(using=using).execute_sql(return_id)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 791, in execute_sql
        cursor = super(SQLInsertCompiler, self).execute_sql(None)
      File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
        cursor.execute(sql, params)
      File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py", line 34, in execute
        return self.cursor.execute(sql, params)
      File "/usr/local/lib/python2.7/dist-packages/django/db/backends/mysql/base.py", line 86, in execute
        return self.cursor.execute(query, args)
      File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 176, in execute
        if not self._defer_warnings: self._warning_check()
      File "/usr/local/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 92, in _warning_check
        warn(w[-1], self.Warning, 3)
    _mysql_exceptions.Warning: Incorrect string value: '\xD0\xA0\xD0\xB5\xD0\xB3...' for column 'name' at row 1

please, help =)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

狼性发作 2025-01-04 14:36:54

该字符串看起来像 utf-8 编码的字符串。如果你的数据库是latin-1编码的(mysql通常默认是这样的)那么这可能是你的麻烦的根源。

检查数据库的字符编码。 具体方法如下

还要检查 python 解释器的默认编码:

sys.getdefaultencoding()

如果这是您正在使用的全新数据库,那么从一开始就将其设置为 utf-8 可能是个好主意。

CREATE DATABASE new_db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci

That string looks like a utf-8 encoded string. If your database is latin-1 encoded (as mysql often is by default) then that could be the source of your trouble.

Check the character encoding of your database. Here's how.

Also check the default encoding of your python interpreter:

sys.getdefaultencoding()

If this is a brand new database you're working on, it's probably a good idea to have it as utf-8 from the start.

CREATE DATABASE new_db DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文