dreipol / djangocms-spa-vue-js

Run your django CMS project as a single-page application (SPA) with vue.js and vue-router.
MIT License
61 stars 9 forks source link

Page translations support - if all languages of one page aren't published site starts raising the `Title matching query does not exist error` #6

Open viktor-yunenko opened 4 years ago

viktor-yunenko commented 4 years ago

Reproduction

``` Environment: Request Method: GET Request URL: https://stage.ch.aldryn.io/it/test-it-copy/?edit_off Django Version: 1.11.27 Python Version: 3.6.3 Installed Applications: ['taggit', 'meta_tagger', 'modeltranslation', 'translations', 'aldryn_addons', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'aldryn_sso', 'djangocms_admin_style', 'django.contrib.admin', 'django.contrib.staticfiles', 'aldryn_django', 'aldryn_sites', 'cms', 'aldryn_django_cms', 'menus', 'sekizai', 'treebeard', 'parler', 'aldryn_boilerplates', 'django.contrib.sitemaps', 'compressor', 'robots', 'captcha', 'django_select2', 'filer.contrib.django_cms', 'aldryn_google_analytics', 'djangocms_file', 'djangocms_googlemap', 'djangocms_history', 'djangocms_link', 'djangocms_picture', 'djangocms_snippet', 'djangocms_style', 'djangocms_text_ckeditor', 'djangocms_video', 'filer', 'easy_thumbnails', 'mptt', 'polymorphic', 'constance', 'constance.backends.database', 'djangocms_spa', 'djangocms_spa_vue_js', 'rest_framework', 'adminsortable2', 'dreicore', 'contents', 'products', 'spa_serializer', 'contactrequests', 'translator', 'lockdown'] Installed Middleware: ['cms.middleware.utils.ApphookReloadMiddleware', 'django.middleware.gzip.GZipMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'aldryn_sso.middleware.AccessControlMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sites.middleware.CurrentSiteMiddleware', 'aldryn_sites.middleware.SiteMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'cms.middleware.user.CurrentUserMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.language.LanguageCookieMiddleware', 'lockdown.middleware.LockdownMiddleware'] Traceback: File "/virtualenv/lib/python3.6/site-packages/django/core/handlers/exception.py" in inner 41. response = get_response(request) File "/virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _legacy_get_response 249. response = self._get_response(request) File "/virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 217. response = self.process_exception_by_middleware(e, request) File "/virtualenv/lib/python3.6/site-packages/django/core/handlers/base.py" in _get_response 215. response = response.render() File "/virtualenv/lib/python3.6/site-packages/django/template/response.py" in render 107. self.content = self.rendered_content File "/virtualenv/lib/python3.6/site-packages/django/template/response.py" in rendered_content 84. content = template.render(context, self._request) File "/virtualenv/lib/python3.6/site-packages/django/template/backends/django.py" in render 66. return self.template.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 207. return self._render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in _render 199. return self.nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/loader_tags.py" in render 177. return compiled_parent._render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in _render 199. return self.nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/classytags/core.py" in render 154. return self.render_tag(context, **kwargs) File "/virtualenv/lib/python3.6/site-packages/sekizai/templatetags/sekizai_tags.py" in render_tag 88. rendered_contents = nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/classytags/core.py" in render 154. return self.render_tag(context, **kwargs) File "/virtualenv/lib/python3.6/site-packages/cms/templatetags/cms_tags.py" in render_tag 499. rendered_contents = nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/classytags/core.py" in render 154. return self.render_tag(context, **kwargs) File "/virtualenv/lib/python3.6/site-packages/sekizai/templatetags/sekizai_tags.py" in render_tag 88. rendered_contents = nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/loader_tags.py" in render 72. result = block.nodelist.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render 990. bit = node.render_annotated(context) File "/virtualenv/lib/python3.6/site-packages/django/template/base.py" in render_annotated 957. return self.render(context) File "/virtualenv/lib/python3.6/site-packages/django/template/library.py" in render 203. output = self.func(*resolved_args, **resolved_kwargs) File "/virtualenv/lib/python3.6/site-packages/djangocms_spa_vue_js/templatetags/router_tags.py" in vue_js_router 17. router = get_vue_js_router(context=context) File "/virtualenv/lib/python3.6/site-packages/djangocms_spa_vue_js/menu_helpers.py" in get_vue_js_router 24. menu_nodes = menu_renderer.get_nodes() File "/virtualenv/lib/python3.6/site-packages/django/utils/functional.py" in __wrapper__ 115. return getattr(res, method_name)(*args, **kw) File "/virtualenv/lib/python3.6/site-packages/menus/menu_pool.py" in get_nodes 246. breadcrumb=breadcrumb, File "/virtualenv/lib/python3.6/site-packages/menus/menu_pool.py" in apply_modifiers 230. self.request, nodes, namespace, root_id, post_cut, breadcrumb) File "/virtualenv/lib/python3.6/site-packages/djangocms_spa_vue_js/cms_menus.py" in modify 45. node_route = get_node_route(request=request, node=node, renderer=self.renderer) File "/virtualenv/lib/python3.6/site-packages/djangocms_spa_vue_js/menu_helpers.py" in get_node_route 72. route = get_node_route_for_cms_page(request, node, route_data) File "/virtualenv/lib/python3.6/site-packages/djangocms_spa_vue_js/menu_helpers.py" in get_node_route_for_cms_page 109. cms_page_title = cms_page.title_set.get(language=request.LANGUAGE_CODE) File "/virtualenv/lib/python3.6/site-packages/django/db/models/manager.py" in manager_method 85. return getattr(self.get_queryset(), name)(*args, **kwargs) File "/virtualenv/lib/python3.6/site-packages/django/db/models/query.py" in get 380. self.model._meta.object_name Exception Type: DoesNotExist at /it/test-it-copy/ Exception Value: Title matching query does not exist. ```

I suspect that's the problematic piece of code:

image

viktor-yunenko commented 4 years ago

And I believe there's a similar problem but it breaks only one page. Yet I wasn't able to reproduce it because now I'm getting the error from above all the time instead.

Approximately the following has happened:

Publishing of the missing translations resolved the problem. But again when I'm trying to reproduce it I'm only getting this other error related to the page title. Which is also fixable by publishing of all the pages.

Still it looks critical since on a production server the editor simply starts getting a 500 error.

viktor-yunenko commented 4 years ago

Based on the git history it looks as the website that I was debugging was developed by Dreipol, maybe you saw that issue before? It might be project specific (CMS 3.4 is a bit old), but I wanted to ask you anyway.

chschuermann commented 4 years ago

HI @victor-yunenko. We no longer actively develop this package and do not have many projects depending on it. If you are able to find a nice solution we are happy to merge a PR.