infoportugal / wagtail-modeltranslation

Simple app to patch modeltranslation (https://github.com/deschler/django-modeltranslation) into Wagtail CMS.
151 stars 119 forks source link

fix contrib.redirects so that redirects work for localized URLs #327

Open Pomax opened 3 years ago

Pomax commented 3 years ago

I've written https://github.com/mozilla/foundation.mozilla.org/blob/master/network-api/networkapi/wagtailcustomization/redirects/middleware.py as a wrapper around wagtail.contrib.redirects, so that setting a redirect for /somepage in the CMS will kick in for any /en/somepage, /fr/somepage, etc. etc, but it might be worth moving that into the wagtail-modeltranslation repo instead, with a docs update that explains to use 'wagtail_modeltranslation.middleware.RedirectMiddleware' rather than 'wagtail.contrib.redirects.middleware.RedirectMiddleware' in the MIDDLEWARE = [...] section of the Django settings.

If that sounds like a good idea, I can form a PR with the relevant code and docs changes.

Pomax commented 3 years ago

I've also filed https://github.com/infoportugal/wagtail-modeltranslation/issues/327 to see if it makes sense to move our solution into wagtail-modeltranslation instead (since it solves a problem that is a consequence of using wagtail-modeltranslation rather than some other localization solution)

DiogoMarques29 commented 3 years ago

Hello @Pomax Sorry for the waiting. Sounds like a good idea. You can go ahead and make a PR! Thanks