I'm trying to deploy a website with wagtail 2.11 on pythonanywhere. However, I'm unable to save any page models in the frontend.
The cause seems to be that in my 'home'-app, migration 0002_create_homepage.py cannot be not applied. Trying so gives me this error (IntegrityError: (1048, "Column 'locale_id' cannot be null")):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/base.py", line 85, in wrapped
res = handle_func(*args, **kwargs)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 243, in handle
post_migrate_state = executor.migrate(
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/migrations/executor.py", line 227, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/migrations/migration.py", line 121, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 190, in database_forwards
self.code(from_state.apps, schema_editor)
File "/home/yogagarten/yogagarten.pythonanywhere.com/home/migrations/0002_create_homepage.py", line 21, in create_homepage
homepage = HomePage.objects.create(
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/query.py", line 447, in create
obj.save(force_insert=True, using=self.db)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 753, in save
self.save_base(using=using, force_insert=force_insert,
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 789, in save_base
parent_inserted = self._save_parents(cls, using, update_fields)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 818, in _save_parents
updated = self._save_table(
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 895, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/base.py", line 933, in _do_insert
return manager._insert(
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/query.py", line 1254, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1397, in execute_sq
l
cursor.execute(sql, params)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 66, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 75, in _execute_with_wra
ppers
return executor(sql, params, many, context)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/yogagarten/.virtualenvs/myvirtualenv/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 78, in execute
raise IntegrityError(*tuple(e.args))
django.db.utils.IntegrityError: (1048, "Column 'locale_id' cannot be null")
My settings.py
INSTALLED_APPS = [
'wagtail.locales',
]
LANGUAGE_CODE = 'de-DE'
LANGUAGES = [('de', 'German'),]
WAGTAILADMIN_PERMITTED_LANGUAGES = [('de', 'German'),]
TIME_ZONE = 'Europe/Berlin'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Basic model example:
class HomePage(Page):
template = 'home/index.html'
ueberschrift = models.CharField(max_length=60, blank=False, null=True)
content_panels = ([FieldPanel('ueberschrift')])
class Meta:
verbose_name = 'Startseite'
I haven't created any page objects yet.
Can you give me some advice on how to fix this error? I understand that every page model comes with a locale field. But I don't know what to do with that info.
What I've tried:
- redid everything with a new database
- reset the language settings to default (en-us)
- I tried the run_before command.
- I checked this answer and followed this part of the official documentation
I'm using wagtail 2.11 with django 3.1.3 and python 3.8.
Thanks so much!