1. Carl Meyer
  2. django-localeurl
  3. Issues
Issue #10 resolved

Wrong redirection url

iro
created an issue

The "Location:" set by LocaleURLMiddleware.process_request does not honor the script_prefix.

For example, if my django project is available under:

http://www.site.com/a/b/c/

for the english language it's been redirected to:

http://www.site.com/en/

instead of:

http://www.site.com/a/b/c/en/

I think the problem is related to the use of utils.locale_path() instead of utils.locale_url() while creating the redirection url. I'll attach a patch that does this and that Works For Me(tm).

Comments (10)

  1. Rochaix Olivier

    Hi iro!

    Thanks I just try and it works ! I made the same change in change_locale view. It works like a charm. As I don't know how to create a *.patch file, here is the code :

    l.22 path = utils.locale_path(path, locale)

    --> path = utils.locale_url(path, locale)

  2. lkraav

    hi guys, also bumped into this now. will be applying the patch next. carljm, any time sometime in the near future to wrap this into trunk?

  3. jmagnusson

    I'm getting infinite redirects with your fix, Carl. I used ori's patch before updating with no problems whatsoever before updating to your commit. Any ideas what could be causing this?

  4. Carl Meyer repo owner

    Whoops, yes, my fix was wrong. Thanks for the report!

    I'm still not using iro's patch exactly, as it requires some work to be done twice unnecessarily, but I've now fixed the infinite redirect in 7f00b6ccab05 -- this version has the same effect as iro's patch.

  5. Log in to comment