django.db.utils.IntegrityError: NOT NULL constraint failed: wagtailimages_image.width
Closed this issue · 7 comments
abitrolly commented
I can't recreate local development environment after 0005_add_jury_data
migration. Might be SQLite issue.
...
Applying results.0004_filmpage... OK
Applying results.0005_add_jury_data...Traceback (most recent call last):
...
File "...django\db\migrations\migration.py", line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "...django\db\migrations\operations\special.py", line 183, in database_forwards
self.code(from_state.apps, schema_editor)
File "C:\__droid\next.filmfest.by\results\migrations\0005_add_jury_data.py", line 74, in add_jury_member_pages
photo.file.save(name=item['photo'], content=File(photo_file))
File "...django\db\models\fields\files.py", line 111, in save
self.instance.save()
File "...django\db\models\base.py", line 708, in save
force_update=force_update, update_fields=update_fields)
File "...django\db\models\base.py", line 736, in save_base
updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "...django\db\models\base.py", line 820, in _save_table
result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "...django\db\models\base.py", line 859, in _do_insert
using=using, raw=raw)
File "...django\db\models\manager.py", line 122, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "...django\db\models\query.py", line 1039, in _insert
return query.get_compiler(using=using).execute_sql(return_id)
File "...django\db\models\sql\compiler.py", line 1060, in execute_sql
cursor.execute(sql, params)
File "...django\db\backends\utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "...django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "...django\db\utils.py", line 95, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "...django\db\backends\utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "...django\db\backends\sqlite3\base.py", line 323, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.IntegrityError: NOT NULL constraint failed: wagtailimages_image.width
staaas commented
@abitrolly could you please also attach the output of pip freeze
?
abitrolly commented
>.v\Scripts\pip freeze
beautifulsoup4==4.5.0
Django==1.9.8
django-debug-toolbar==1.5
django-modelcluster==2.0
django-taggit==0.18.3
django-treebeard==4.0.1
djangorestframework==3.4.0
elasticsearch==2.1.0
html5lib==0.999999999
Pillow==3.3.0
pluggy==0.3.1
psycopg2==2.6.2
py==1.4.31
pycountry==0.14.2
pytz==2016.6.1
six==1.10.0
sqlparse==0.2.0
tox==2.3.1
Unidecode==0.4.19
urllib3==1.16
virtualenv==15.0.2
wagtail==1.6rc1
webencodings==0.5
Willow==0.3.1
abitrolly commented
I couldn't repeat this on Linux, but got it repeatable on Windows- https://ci.appveyor.com/project/abitrolly/next-filmfest-by
abitrolly commented
So far I traced this back to this hack
- where is the upstream bug for that?If I remove the hack, the error changes to:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "...django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "...django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "...django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "...django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "...django\core\management\commands\migrate.py", line 200, in handle
executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial)
File "...django\db\migrations\executor.py", line 92, in migrate
self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial)
File "...django\db\migrations\executor.py", line 121, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "...django\db\migrations\executor.py", line 198, in apply_migration
state = migration.apply(state, schema_editor)
File "...django\db\migrations\migration.py", line 123, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "...django\db\migrations\operations\special.py", line 183, in database_forwards
self.code(from_state.apps, schema_editor)
File "next.filmfest.by\results\migrations\0005_add_jury_data.py", line 78, in add_jury_member_pages
photo.file.save(name=item['photo'], content=File(photo_file))
File "...django\db\models\fields\files.py", line 90, in save
name = self.field.generate_filename(self.instance, name)
File "...django\db\models\fields\files.py", line 328, in generate_filename
directory_name, filename = os.path.split(self.upload_to(instance, filename))
File "...wagtail\wagtailimages\models.py", line 55, in get_upload_to
return instance.get_upload_to(filename)
AttributeError: 'Image' object has no attribute 'get_upload_to'
davojta commented
Seems that bug connected with update to new wagtail version
abitrolly commented
Migration order is the same on Linux and Windows.