You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
wagtail.contrib.forms.models.AbstractForm subclasses without a template attribute cannot be instantiated in migrations.
gitpod /workspace/wagtail-gitpod (main) $ ./manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, home, sessions, taggit, wagtailadmin, wagtailcore, wagtaildocs, wagtailembeds, wagtailforms, wagtailimages, wagtailredirects, wagtailsearch, wagtailusers
Running migrations:
Applying home.0007_migrate_form_page...Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
utility.execute()
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/__init__.py", line 436, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/base.py", line 412, in run_from_argv
self.execute(*args, **cmd_options)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/base.py", line 458, in execute
output = self.handle(*args, **options)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/base.py", line 106, in wrapper
res = handle_func(*args, **kwargs)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/core/management/commands/migrate.py", line 356, in handle
post_migrate_state = executor.migrate(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/migrations/executor.py", line 135, in migrate
state = self._migrate_all_forwards(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/migrations/executor.py", line 167, in _migrate_all_forwards
state = self.apply_migration(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/migrations/executor.py", line 252, in apply_migration
state = migration.apply(state, schema_editor)
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/migrations/migration.py", line 132, in apply
operation.database_forwards(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/migrations/operations/special.py", line 193, in database_forwards
self.code(from_state.apps, schema_editor)
File "/workspace/wagtail-gitpod/home/migrations/0007_migrate_form_page.py", line 8, in migrate_form_page
for page in FormPage.objects.all():
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/models/query.py", line 398, in __iter__
self._fetch_all()
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/models/query.py", line 1881, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/models/query.py", line 122, in __iter__
obj = model_cls.from_db(
File "/workspace/.pip-modules/lib/python3.8/site-packages/django/db/models/base.py", line 582, in from_db
new = cls(*values)
File "/workspace/.pip-modules/lib/python3.8/site-packages/wagtail/contrib/forms/models.py", line 178, in __init__
name, ext = os.path.splitext(self.template)
AttributeError: 'FormPage' object has no attribute 'template'
There are scenarios where users might not explicitly declare template or landing_page_template attributes:
Issue Summary
wagtail.contrib.forms.models.AbstractForm
subclasses without atemplate
attribute cannot be instantiated in migrations.There are scenarios where users might not explicitly declare
template
orlanding_page_template
attributes:Steps to Reproduce
wagtail start myproject
./manage.py makemigrations
./manage.py migrate
FormPage
../manage.py makemigrations --empty -n migrate_form_page home
./manage.py migrate
This will cause the error.
Technical details
Working on this
I am happy to submit a patch for this issue
The text was updated successfully, but these errors were encountered: