Open nimasmi opened 4 years ago
Thanks for reporting!
This is happening because errors are currently saved against translations, but in this case, it's failing on the original, untranslated slug value coming from the English page so there's nowhere to put the error.
A workaround for this would be to pass the slug into Wagtail's find_available_slug
function which will check if the slug is available and append a -1
, -2
, etc to the end if not.
Hey @kaedroho is it possible for me to see the exact validation error somehow (print it out in the server or browser console)?
I'm running into this exact issue with a page that's in translation sync mode (so not a separate page). I don't think the slug is the issue since we use SynchronizedField for the slug which should be fine with non-unique slugs (which works for every other page and even other pages of the same type site-wide).
override_translatable_fields = [
SynchronizedField('slug', overridable=False),
]
Oddly enough, if i click stop translation sync
on the page then publish it, it'll successfully publish...
So I feel like, at least in my case, it's not the slug but some page field data it doesn't like.
I've already tried these things:
The only thing I can think of that's left to try is to delete and re-create the pages (and translations) from scratch...but I'm trying to avoid that since it'll take quite a bit of time to re-enter everything).
Does anyone have any tips on how to troubleshoot this more or at least get a verbose output of the full error somehow?
Facing the same problem. Has somebody any idea on how to solve this?
May or may not be relevant -
I had this issue with a snippet with unique_together constraint:
unique_together = ('translation_key', 'locale'), ('locale', 'slug')
It would show the problem as described by OP, and throw an unhandled error when translating a page using linked to this model if a slug was repeated in the locale.
I needed to make a custom field type to take care of the validation:
class CategorySlugField(models.SlugField):
def validate(self, value, instance, *args, **kwargs):
super().validate(self, value)
cat_type = instance.__class__
found = cat_type.objects.filter(locale=instance.locale.id).filter(slug=instance.slug).exclude(pk=instance.pk)
if found.count()>0:
raise ValidationError(_(f"'{instance.slug}' is already in use by '{found.first()}'. Please select a unique slug."))
If I translate then immediately ask to publish the home page in French, I get an error message at the top of the page, but no details about the specific error.
Steps to reproduce
home
.home_fr
.When the error is reported, the error message is only the red banner at the top of the admin, and there's no error styling on the tabs or the 'slug' field.