Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WAGTAILLOCALIZE_SYNC_LIVE_STATUS_ON_TRANSLATE = False causes a CannotSaveDraftError when translating a snippet. #724

Closed
DEWaller opened this issue Oct 2, 2023 · 4 comments · Fixed by #726

Comments

@DEWaller
Copy link

DEWaller commented Oct 2, 2023

WAGTAILLOCALIZE_SYNC_LIVE_STATUS_ON_TRANSLATE = False causes a 'CannotSaveDraftError' in \Lib\site-packages\wagtail_localize\models.py, line 739 when translating a snippet.

Django==4.2.5
wagtail==5.1.2
wagtail-localize==1.5.2

class HeaderTitle(TranslatableMixin, models.Model):
    title = models.CharField(max_length=100)

    panels = [
        FieldPanel('title'),
    ]

    def __str__(self):
        return self.title```
@zerolab
Copy link
Collaborator

zerolab commented Oct 2, 2023

please provide a full traceback

@DEWaller
Copy link
Author

DEWaller commented Oct 2, 2023

Environment:


Request Method: POST
Request URL: http://127.0.0.1:8000/admin/localize/submit/snippet/home/headertitle/4/

Django Version: 4.2.3
Python Version: 3.11.1
Installed Applications:
['home',
 'menus',
 'search',
 'streams',
 'compressor',
 'wagtail.contrib.forms',
 'wagtail.contrib.redirects',
 'wagtail.embeds',
 'wagtail.sites',
 'wagtail.users',
 'wagtail.snippets',
 'wagtail.documents',
 'wagtail.images',
 'wagtail.search',
 'wagtail.admin',
 'wagtail_localize',
 'wagtail_localize.locales',
 'wagtail_localize.modeladmin',
 '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:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
    response = get_response(request)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\django\views\decorators\cache.py", line 62, in _wrapper_view_func
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail\admin\urls\__init__.py", line 180, in wrapper
    return view_func(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail\admin\auth.py", line 165, in decorated_view
    response = view_func(request, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\django\views\generic\base.py", line 104, in view
    return self.dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\views\submit_translations.py", line 174, in dispatch
    return super().dispatch(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\django\views\generic\base.py", line 143, in dispatch
    return handler(request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\views\submit_translations.py", line 118, in post
    return self.form_valid(form)
           ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\views\submit_translations.py", line 125, in form_valid
    translate_object(
    ^
  File "C:\Python311\Lib\contextlib.py", line 81, in inner
    return func(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\operations.py", line 93, in translate_object
    translator.create_translations(instance)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\operations.py", line 82, in create_translations
    translation.save_target(user=self.user, publish=publish)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\models.py", line 1331, in save_target
    self.source.create_or_update_translation(
    ^
  File "C:\Users\David\Dropbox\Wagtail projects\naturani\env\Lib\site-packages\wagtail_localize\models.py", line 739, in create_or_update_translation
    raise CannotSaveDraftError
    ^^^^^^^^^^^^^^^^^^^^^^^^^^

Exception Type: CannotSaveDraftError at /admin/localize/submit/snippet/home/headertitle/4/
Exception Value: 

@zerolab
Copy link
Collaborator

zerolab commented Oct 3, 2023

Thank you. Will have a look in the next few days

@zerolab
Copy link
Collaborator

zerolab commented Oct 6, 2023

@DEWaller should be fixed in https://github.com/wagtail/wagtail-localize/releases/tag/v1.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants