Beim Versuch, die Admin-Migrationen zu laufen (0002_logentry_remove_auto_add) erhalte ich die Fehlermeldung:Django (42000): Ungültige Standardwert für ‚ACTION_TIME‘
mysql.connector.errors.ProgrammingError: 1067 (42000): Invalid default value for 'action_time'
nicht sicher, was ist der Grund dafür habe ich eine Quelle kompilierte Version von mysql (5.5.50) was vielleicht etwas damit zu tun hat.
Django Lauf 1.9.2 mit mysql-connector-Python 2.1.3
bearbeiten Traceback:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/core/management/commands/migrate.py", line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/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 "/home/bischoff_s/Code/venvs/gec/lib/python3.5/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 "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/migrations/executor.py", line 198, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/migrations/migration.py", line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/migrations/operations/fields.py", line 201, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 482, in alter_field
old_db_params, new_db_params, strict)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 634, in _alter_field
params,
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/backends/base/schema.py", line 110, in execute
cursor.execute(sql, params)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/django/base.py", line 227, in execute
return self._execute_wrapper(self.cursor.execute, query, new_args)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/django/base.py", line 180, in _execute_wrapper
utils.ProgrammingError(err.msg), sys.exc_info()[2])
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/django/base.py", line 177, in _execute_wrapper
return method(query, args)
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/cursor.py", line 515, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/connection.py", line 488, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
File "/home/bischoff_s/Code/venvs/gec/lib/python3.5/site-packages/mysql/connector/connection.py", line 395, in _handle_result
raise errors.get_exception(packet)
django.db.utils.ProgrammingError: Invalid default value for 'action_time'
bearbeiten Mehr:
ipdb> stmt
b"ALTER TABLE `django_admin_log` ALTER COLUMN `action_time` SET DEFAULT '2016-07-25 17:58:03.214262+00:00'"
ipdb> self._connection.cmd_query(stmt)
*** mysql.connector.errors.ProgrammingError: 1067 (42000): Invalid default value for 'action_time'
Ich bin nicht sicher, warum die Datenbank diese Daten nicht als gültigen Standard übernehmen ...
timezone.now, aber es ist eine Standardmigration, die mit Django (Admin-Modell) geliefert wird – bischoffingston
Es ist etwas komisch, weil Django keine Standardwerte in der Datenbank setzt. Bitte zeigen Sie den vollständigen Traceback an. –
Wie würde Django keine Standardwerte festlegen, wenn ein Standardschlüsselwort bei Migrationen vorhanden ist? Fehle ich etwas? – bischoffingston