title: Why is request.session['django_language'] is being overriden by browser preferred language?
body: <p>Using Django, I'd like users to be able to choose the site language.</p>
  
  <p>It is working perfectly fine when the user preferred language set in browser is English.
  User can switch between English and Portuguese as expected.</p>
  
  <p>However, when I change my browser preferred language the language switcher stops working (I tested in Opera, Google Chrome, Firefox and Epiphany - couldn't test on IE or Safari).</p>
  
  <p>I suppose I did something wrong, but cannot figure out what. It puzzles me that it works fine when the preferred language is set back to default... </p>
  
  <p>Django documentation says it will use the following to choose the language:</p>
  
  <blockquote>
    <p>First, it looks for a django_language key in the current user’s
    session.
      Failing that, it looks for a cookie.
      Failing that, it looks at the Accept-Language HTTP header. This header is sent by your browser and tells the server which language(s) you prefer, in order by priority. Django tries each language in the header until it finds one with available translations.
      Failing that, it uses the global LANGUAGE_CODE setting.</p>
  </blockquote>
  
  <p>Why am I getting a different behavior in the language switcher when browser has a preferred language than when it has the default? </p>
  
  <hr>
  
  <p>My settings.py respecting middleware is as follows</p>
  
  <pre><code>MIDDLEWARE_CLASSES = ( 
      'django.contrib.sessions.middleware.SessionMiddleware', 
      'django.middleware.locale.LocaleMiddleware', 
      'django.middleware.common.CommonMiddleware', 
      'django.middleware.csrf.CsrfViewMiddleware', 
      'django.contrib.auth.middleware.AuthenticationMiddleware', 
      'django.contrib.messages.middleware.MessageMiddleware', 
  ) 
  </code></pre>
  
  <p>My locale folder contains the structure:</p>
  
  <pre><code>locale/
      pt_BR/
          LC_MESSAGES/
              django.mo
              django.po
  </code></pre>
  
  <p>My language switcher (in the template) is as follows:</p>
  
  <pre><code>    &lt;div id="secondary-menu" class="navigation"&gt;
          &lt;ul class="menu"&gt;
              &lt;li&gt;&lt;a href="/about-us" &gt; {{ second1 }}&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a href="/free-culture" &gt; {{ second2 }}&lt;/a&gt;&lt;/li&gt;
              &lt;li&gt;&lt;a &gt; {{ second3 }}&lt;/a&gt;
                  &lt;ul&gt;
                      &lt;li&gt;&lt;form name="setLangEnglish" method="post" action="/i18n/setlang/"&gt;{% csrf_token %}
                          &lt;input name="next" type="hidden" value="/" /&gt;
                          &lt;input type="hidden" name="language" value="en-us"/&gt;
                          &lt;input class="language-switcher" type="submit" alt="English" name="submit" value="English"/&gt;
                          &lt;/form&gt;
                      &lt;/li&gt;
                      &lt;li&gt;&lt;form name="setLangPortuguese" method="post" action="/i18n/setlang/"&gt;{% csrf_token %}
                           &lt;input name="next" type="hidden" value="/" /&gt;
                           &lt;input type="hidden" name="language" value="pt-br"/&gt;
                          &lt;input class="language-switcher" type="submit" alt="Portugues" name="submit" value="Portugues"/&gt;
                          &lt;/form&gt;
                      &lt;/li&gt;
                  &lt;/ul&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/div&gt;
  </code></pre>