Public bug reported:
(Be warned, I am a novice and this may be a novice mistake):
I mistakenly added a TimeField instead of a DurationField to my model.
I was forced to give it a default value and chose TimeDelta(minutes=30).
The makemigration worked, but the migrate command crashed with very
unhelpful diagnostics, not even indicating which field caused the
problem.
I'm hoping that this lack of diagnostics could be improved, to at least
point to the database column that caused the problem?
Thanks in advance for all the good stuff you do :-)
Simon Lambourn.
Output from manage.py migrate:
Operations to perform:
Apply all migrations: admin, auth, contenttypes, kitten, sessions
Running migrations:
Applying kitten.0010_auto_20200428_0957...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py",
line 364, in execute_from_command_line
utility.execute()
File "/usr/lib/python3/dist-packages/django/core/management/__init__.py",
line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line
283, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/lib/python3/dist-packages/django/core/management/base.py", line
330, in execute
output = self.handle(*args, **options)
File
"/usr/lib/python3/dist-packages/django/core/management/commands/migrate.py",
line 204, in handle
fake_initial=fake_initial,
File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line
115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake,
fake_initial=fake_initial)
File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line
145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake,
fake_initial=fake_initial)
File "/usr/lib/python3/dist-packages/django/db/migrations/executor.py", line
244, in apply_migration
state = migration.apply(state, schema_editor)
File "/usr/lib/python3/dist-packages/django/db/migrations/migration.py", line
129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state,
project_state)
File
"/usr/lib/python3/dist-packages/django/db/migrations/operations/fields.py",
line 88, in database_forwards
field,
File "/usr/lib/python3/dist-packages/django/db/backends/sqlite3/schema.py",
line 240, in add_field
self._remake_table(model, create_field=field)
File "/usr/lib/python3/dist-packages/django/db/backends/sqlite3/schema.py",
line 115, in _remake_table
self.effective_default(create_field)
File "/usr/lib/python3/dist-packages/django/db/backends/base/schema.py", line
245, in effective_default
default = field.get_db_prep_save(default, self.connection)
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py",
line 770, in get_db_prep_save
prepared=False)
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py",
line 2281, in get_db_prep_value
value = self.get_prep_value(value)
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py",
line 2276, in get_prep_value
return self.to_python(value)
File "/usr/lib/python3/dist-packages/django/db/models/fields/__init__.py",
line 2250, in to_python
parsed = parse_time(value)
File "/usr/lib/python3/dist-packages/django/utils/dateparse.py", line 76, in
parse_time
match = time_re.match(value)
TypeError: expected string or bytes-like object
ProblemType: Bug
DistroRelease: Ubuntu 19.10
Package: python3-django 1:1.11.22-1ubuntu1.3
ProcVersionSignature: Ubuntu 5.3.0-46.38-generic 5.3.18
Uname: Linux 5.3.0-46-generic x86_64
ApportVersion: 2.20.11-0ubuntu8.8
Architecture: amd64
CurrentDesktop: ubuntu:GNOME
Date: Tue Apr 28 09:59:25 2020
PackageArchitecture: all
SourcePackage: python-django
UpgradeStatus: Upgraded to eoan on 2019-10-23 (187 days ago)
** Affects: python-django (Ubuntu)
Importance: Undecided
Status: New
** Tags: amd64 apport-bug eoan
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1875596
Title:
Django Timefield(default=<TimeDelta>) gives unhelpful diagnostics
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/python-django/+bug/1875596/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs