wagtail / wagtail-localize

Translation plugin for Wagtail CMS
https://wagtail-localize.org/
Other
226 stars 86 forks source link

ProgrammingError trying to delete locale home pages on vanilla build #663

Closed enzedonline closed 1 year ago

enzedonline commented 1 year ago

I'm setting up a test site for localize code building. When I try to delete the created homepage for any locale, I get the following error:

ProgrammingError at /admin/pages/3/delete/
relation "home_homepage" does not exist
LINE 1: ..."alias_of_id", "home_homepage"."page_ptr_id" FROM "home_home...

This is still a vanilla site, no extra apps have been added, nor the home app amended.

Locales added as:

WAGTAIL_CONTENT_LANGUAGES = LANGUAGES = [
    ('en-GB', "English (Great Britain)"),
    ('en-US', "English (United States)"),
    ('en-CA', "English (Canada)"),
    ('fr-FR', "French (France)"),
    ('fr-CA', "French (Canada)"),
]

(Not what I intended, which is why I'm trying to delete the homepages and locales).

To recreate issue, add each as a locale, translate default homepage.

Code for the site can be cloned from https://github.com/enzedonline/testlocalize

Django Version: 4.1.3 Python Version: 3.10.6 Wagtail Version: 4.1.1 Wagtail-localize Version: 1.3.3

Traceback:

Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/pages/3/delete/

Django Version: 4.1.3
Python Version: 3.10.6
Installed Applications:
['home',
 'search',
 'wagtail_localize',
 'wagtail_localize.locales',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.search',
 'wagtail.admin',
 'wagtail',
 'modelcluster',
 'taggit',
 'django.contrib.admin',
 'django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.messages',
 'django.contrib.staticfiles']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.middleware.clickjacking.XFrameOptionsMiddleware',
 'django.middleware.security.SecurityMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'wagtail.contrib.redirects.middleware.RedirectMiddleware']

Traceback (most recent call last):
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

The above exception (relation "home_homepage" does not exist
LINE 1: ..."alias_of_id", "home_homepage"."page_ptr_id" FROM "home_home...
                                                             ^
) was the direct cause of the following exception:
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\views\decorators\cache.py", line 62, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\admin\urls\__init__.py", line 170, in wrapper
    return view_func(request, *args, **kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\admin\auth.py", line 182, in decorated_view
    response = view_func(request, *args, **kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\admin\views\pages\delete.py", line 57, in delete
    action.execute(skip_permission_checks=True)
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\actions\delete_page.py", line 51, in execute
    return self._delete_page(self.page, *args, **kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\actions\delete_page.py", line 41, in _delete_page
    return super(Page, page).delete(*args, **kwargs)
  File "C:\Django\testlocalize\.venv\lib\site-packages\treebeard\models.py", line 504, in delete
    self.__class__.objects.filter(pk=self.pk).delete()
  File "C:\Django\testlocalize\.venv\lib\site-packages\wagtail\query.py", line 25, in delete
    super().delete()
  File "C:\Django\testlocalize\.venv\lib\site-packages\treebeard\mp_tree.py", line 124, in delete
    super(MP_NodeQuerySet, qset).delete()
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\query.py", line 1131, in delete
    collector.collect(del_query)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\deletion.py", line 343, in collect
    if sub_objs:
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\query.py", line 408, in __bool__
    self._fetch_all()
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\query.py", line 1866, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\query.py", line 87, in __iter__
    results = compiler.execute_sql(
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\models\sql\compiler.py", line 1398, in execute_sql
    cursor.execute(sql, params)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 103, in execute
    return super().execute(sql, params)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 67, in execute
    return self._execute_with_wrappers(
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 84, in _execute
    with self.db.wrap_database_errors:
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\utils.py", line 91, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "C:\Django\testlocalize\.venv\lib\site-packages\django\db\backends\utils.py", line 89, in _execute
    return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/pages/3/delete/
Exception Value: relation "home_homepage" does not exist
LINE 1: ..."alias_of_id", "home_homepage"."page_ptr_id" FROM "home_home...
                                                             ^
enzedonline commented 1 year ago

Closed - seems the migration for home didn't apply, re-running fixed that