Changing the language changes the state of your application (it displays
it entirely differently, for a start, and may even change the
information that is presented for defaults, etc). That means it is
inappropriate to be done via an HTTP GET, which should not result in any
significant state change. So that's why Django requires a POST there.
(For bonus points, find the one place in Django's code that doesn't obey
this principle. :-( )
If you want to use GET there, you'll need to write your own view.
> The documentation says that redirect to set_language uses POST data,
> so I guess my question could be rephrased as: How do I use a simple
> link to send POST data to the page I am linking to?
You can't. Href links in HTML are always GET requests. They can
therefore be safely followed by automated processes, etc (cue riotous
laughter from everybody who realises that so many websites don't do
things properly that this isn't true, but the principle is correct).
> And I guess that
> maybe this is not a Django-related question at all!
>
> Still, maybe one of you kind people can help me or at least point me
> in the right direction.
Use Javascript, or write your own view that is like Django's set
language view but allows GET.
Regards,
Malcolm
--
I don't have a solution, but I admire your problem.
http://www.pointy-stick.com/blog/
instead of the ponderous ruminations of the the venerous
mal...@pointy-stick.com, here's a trivial
solution
<div id="languages">
<table >
<tr>
{% for lang in LANGUAGES %}
<td>
{% comment %}
<b>Kind of weird', depending on version, Django wants either
a GET or a POST to set the cookie</b>
{% endcomment %}
<form action="/http_frontend/i18n/setlang/" method="post">
<input type="hidden" name="language" value="{{lang.0}}"/>
<input id="lang_{{lang.0}}" type = "image"
src="/media/http_frontend/img/{{ lang.0 }}.gif" alt="{{ lang.1 }}"/>
</form>
</td>
{% endfor %}
</tr>
</table>
</div>
just pass in LANGUAGES from the settings and provide images
And yes, I was baffled to realize that somehow between early 0.96 and
svn versions it seems to have flipped from
GET to POST. POST is more logical of course
-- tony