Hi,
I am facing the following TypeError
, when running py manage.py migrate:
(venv) PS C:\Users\Name\codingprojects\CoderMatching\codermatching> py manage.py migrate
System check identified some issues:
WARNINGS:
?: (mysql.W002) MariaDB Strict Mode is not set for database connection 'default'
HINT: MariaDB's Strict Mode fixes many data integrity problems in MariaDB, such as data truncation upon insertion, by escalating warnings into errors. It is strongly recommended you activate it. See: https://docs.djangoproject.com/en/4.0/ref/databases/#mysql-sql-mode
Operations to perform:
Apply all migrations: admin, auth, codermatch, contenttypes, sessions
Running migrations:
Applying codermatch.0031_alter_ad_expirationtime_alter_ad_projectstartdate...Traceback (most recent call last):
File "C:\Users\Name\codingprojects\CoderMatching\codermatching\manage.py", line 22, in <module>
main()
File "C:\Users\Name\codingprojects\CoderMatching\codermatching\manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\__init__.py", line 425, in execute_from_command_line
utility.execute()
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\__init__.py", line 419, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\base.py", line 373, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\base.py", line 417, in execute
output = self.handle(*args, **options)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\base.py", line 90, in wrapped
res = handle_func(*args, **kwargs)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\core\management\commands\migrate.py", line 253, in handle
post_migrate_state = executor.migrate(
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\migrations\executor.py", line 126, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial) File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\migrations\executor.py", line 156, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\migrations\executor.py", line 236, in apply_migration
state = migration.apply(state, schema_editor)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\migrations\migration.py", line 125, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\migrations\operations\fields.py", line 225, in database_forwards
schema_editor.alter_field(from_model, from_field, to_field)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\backends\base\schema.py", line 618, in alter_field
self._alter_field(model, old_field, new_field, old_type, new_type,
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\backends\base\schema.py", line 746, in _alter_field
new_default = self.effective_default(new_field)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\backends\base\schema.py", line 334, in effective_default
return field.get_db_prep_save(self._effective_default(field), self.connection)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\models\fields\__init__.py", line 839, in get_db_prep_save
return self.get_db_prep_value(value, connection=connection, prepared=False)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\models\fields\__init__.py", line 1293, in get_db_prep_value
value = self.get_prep_value(value)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\models\fields\__init__.py", line 1288, in get_prep_value
return self.to_python(value)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\db\models\fields\__init__.py", line 1250, in to_python
parsed = parse_date(value)
File "C:\Users\Name\codingprojects\CoderMatching\venv\lib\site-packages\django\utils\dateparse.py", line 76, in parse_date
return datetime.date.fromisoformat(value)
TypeError: fromisoformat: argument must be str
The migration look like this:
(venv) PS C:\Users\Name\codingprojects\CoderMatching\codermatching> py manage.py makemigrations
Migrations for 'codermatch':
codermatch\migrations\0034_alter_ad_expirationtime.py
- Alter field expirationTime on ad
models.py
class Ad(models.Model):
expirationTime = models.DateTimeField('expiration time (of ad)', default=timezone.now() + datetime.timedelta(days=30))
#... some other properties
settings.py
# Internationalization
# https://docs.djangoproject.com/en/4.0/topics/i18n/
LANGUAGE_CODE = 'de-de'
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_TZ = True
I really donāt understand whatās the issue here.
From my point of view the error message and the traceback arenāt helpful at allā¦
I may only assume that this is caused by the expirationTime property in the Ad model, since itās the only field mentioned, when running py manage.py makemigrations
Maybe someone has a suggestion?