0

in my test I do:

self.client.get('/')

in my template I access:

request.LANGUAGE_CODE

in the browser it works fine with the Django client I get

Failed lookup for key [LANGUAGE_CODE] in ''

From the output I believe that the request is not set in the client.

Similar Issue that didn't help me

ohlr
  • 1,839
  • 1
  • 13
  • 29
  • `LANGUAGE_CODE` is a settings.py configuration. Why do you do a key lookup for such a key in the request in the first place? – Adelin Dec 13 '18 at 12:29
  • request.LANGUAGE_CODE yields 'en' for my .com pages and 'de' for my german pages. This way I link to different sources for each language. – ohlr Dec 13 '18 at 12:36
  • @Adelin Do you see a better way to do this? – ohlr Dec 13 '18 at 12:38
  • ok maybe I don't understand the question/problem then (it's not clear what's happening and at what time) – Adelin Dec 13 '18 at 13:09

1 Answers1

0

I found the error myself:

The test client was working just fine. Some of the sites were really not working.

In my views.py I had the following bug:

wrong code:

return render(some_other_view, 'page.html')

correct code:

return render(request, 'page.html')

ohlr
  • 1,839
  • 1
  • 13
  • 29