Open maxbellec opened 1 year ago
This issue still exists with wagtail-localize 1.7 and Wagtail version 5.2.3 and somewhat related to #10922.
In my case I am using a model to categorize blog posts in categories with a unique slug. Because of the unique field it is not possible to set up translations even after following these steps.
Setting exclude_fields_in_copy = ['slug']
does not help, as copy_synchronized_fields()
is still called in create_or_update_translation()
.
Maybe a callback to "update" the value of unique fields should be implemented. It could append the language code by default.
First off, props for this great piece of software :pray:.
Imagine I want to translate an instance of this model
Tag
Because it inherits from
TagBase
, it will have aslug
field with aunique=True
attribute. When translating from the admin, theTranslationSource
is created fine, but the translated instance, another instance ofTag
but with another locale, fails to be created because the database prevents saving another object with the sameslug
.Because of this line of code : https://github.com/wagtail/wagtail-localize/blob/v1.3.3/wagtail_localize/operations.py#L81, the
ValidationError
is simplypass
ed silently, and the error is hard to debug. The error shown isTag matching query does not exist
that occurs later because the translated instance does not exist. Full example traceback here.Suggestions :
try / except ValidationError
clause and let the user see theValidationError
. I am not so familiar with the internals of wagtail-localize, but I guess there is a good reason for this try/except to be hereValidationError
If it seems relevant for you, I'd be happy to try a PR to add the warning.