internationalization - Django URL Translation - Stay on the same page when changing language -
i developped django app i18n urls well.
that nice when changing language stay on same/previous page.
what best way of doing ?
basically new url need reverse
on name of previous page after having changed language , redirect how can know url name of previous page?
edit:
a solution came collegue:
calculate next parameter each language using request.resolver_match. each language : activate(language) + reverse('{app_name}:{url_name}', args, kwargs)
using request.resolver_match elements
do see better idea?
two options you:
option 1
if use form
documentation take brings page on.
option 2
when changing language use referrer header, http_referer
, , redirect came from
# change language # ... code ... # redirect came redirect_to = request.meta.get('http_referer', reverse('default-redirect-page')) return httpresponseredirect(redirect_to)
Comments
Post a Comment