1
私はDjangoでWeb Developmentを初めて利用しています。学習のためにDjangoチュートリアル(PollsApp)に従っています。私がDjango Adminパネルを起動しようとしているとき、 'tuple'型の非intでシーケンスを掛けることはできません。Django Adminログイン画面でエラーが発生しました
誰かが迷っていることをお伝えできますか?
以下トレースバックです:
***Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/login/?next=/admin/
Django Version: 1.10.1
Python Version: 3.4.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'polls.apps.PollsConfig']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "E:\Python34\lib\site-packages\django\core\handlers\exception.py" in inner
39. response = get_response(request)
File "E:\Python34\lib\site-packages\django\core\handlers\base.py" in _legacy_get_response
249. response = self._get_response(request)
File "E:\Python34\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)
File "E:\Python34\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "E:\Python34\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "E:\Python34\lib\site-packages\django\contrib\admin\sites.py" in login
377. return login(request, **defaults)
File "E:\Python34\lib\site-packages\django\contrib\auth\views.py" in inner
47. return func(*args, **kwargs)
File "E:\Python34\lib\site-packages\django\views\decorators\debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "E:\Python34\lib\site-packages\django\utils\decorators.py" in _wrapped_view
149. response = view_func(request, *args, **kwargs)
File "E:\Python34\lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func
57. response = view_func(request, *args, **kwargs)
File "E:\Python34\lib\site-packages\django\contrib\auth\views.py" in login
82. auth_login(request, form.get_user())
File "E:\Python34\lib\site-packages\django\contrib\auth\__init__.py" in login
109. request.session.cycle_key()
File "E:\Python34\lib\site-packages\django\contrib\sessions\backends\base.py" in cycle_key
311. self.create()
File "E:\Python34\lib\site-packages\django\contrib\sessions\backends\db.py" in create
54. self.save(must_create=True)
File "E:\Python34\lib\site-packages\django\contrib\sessions\backends\db.py" in save
87. obj.save(force_insert=must_create, force_update=not must_create, using=using)
File "E:\Python34\lib\site-packages\django\db\models\base.py" in save
796. force_update=force_update, update_fields=update_fields)
File "E:\Python34\lib\site-packages\django\db\models\base.py" in save_base
824. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "E:\Python34\lib\site-packages\django\db\models\base.py" in _save_table
908. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "E:\Python34\lib\site-packages\django\db\models\base.py" in _do_insert
947. using=using, raw=raw)
File "E:\Python34\lib\site-packages\django\db\models\manager.py" in manager_method
85. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "E:\Python34\lib\site-packages\django\db\models\query.py" in _insert
1045. return query.get_compiler(using=using).execute_sql(return_id)
File "E:\Python34\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
1053. for sql, params in self.as_sql():
File "E:\Python34\lib\site-packages\django\db\models\sql\compiler.py" in as_sql
1038. result.append(self.connection.ops.bulk_insert_sql(fields, placeholder_rows))
File "E:\Python34\lib\site-packages\mysql\connector\django\operations.py" in bulk_insert_sql
223. return "VALUES " + ", ".join([items_sql] * num_values)
Exception Type: TypeError at /admin/login/
Exception Value: can't multiply sequence by non-int of type 'tuple'***
編集 ここでは、settings.pyに私のデータベースを行く:あなたは、ジャンゴの
DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'polls',
'USER': '.....',
'PASSWORD': '.....',
'HOST': 'localhost', # Or an IP Address that your DB is hosted on
'PORT': '4928',
}
}
あなたmakemigrationsと移行がsuccessfuly完了したのですか? – itzMEonTV
実際に私は、マカマイグレーションやマイグレーション中にも同じエラーが発生しました。その時に解決しようとしましたが、何もできませんでした。 – dashakt
MySQL Connector/Pythonで[問題](https://forums.mysql.com/read.php?50,650281,650281#msg-650281)にヒットしました。 [Django docs note](https://docs.djangoproject.com/en/1.11/ref/databases/#id10)は、MySQL Connector/PythonがDjangoの最新バージョンを常にサポートするとは限りません。 DjangoでMySQLを使用する際に推奨される 'mysqlclient'を使う方が簡単です。 – Alasdair