-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server error 500 if no accept_language header is present #2179
Comments
I just spent the last 7 hours encountering this same issue. It's especially a problem when a third-party service (i.e. Instagram) tries to call a callback url without the header set. |
I actually just figured this out, although I don't completely understand the problem. In my case, I had set the available Django LANGUAGES setting to use only one - 'en'. However, the default LANGUAGE_CODE setting is 'en-us'. Accordingly, when requests were made without the language header were made, Django assumed it wanted a response in 'en-us'. In my case, no page actually existed in that language, because my pages only existed in 'en'. The CMS will offer the option to localize the content for every language specified in LANGUAGES. By default, that's every language that Django supports, and results in an admin with a billion language choices. I didn't want that, which is why I set the LANGUAGES to a single choice, and ended up using the wrong language code. |
same issue here, solved it by setting LANGUAGES and LANGUAGE_CODE to matching values. |
Same issue, my languages variables are:
Like @ryanbagwell says, looks like Django are searching a erroneous language, if the page have both language versions, no problem. Also only occurs when the user is sign-in. Tested with the latest 3.0.0.beta3 and Python 2.7. |
fixes #2179 and validates that LANGUAGE_CODE is in LANGUAGES
@digi604 , according with the official Django documentation (https://django.readthedocs.org/en/1.6.x/ref/settings.html#language-code), this is correct:
An also this in the same context (https://django.readthedocs.org/en/1.6.x/ref/settings.html#languages):
But looking your patch, a configuration like this will be raise a
I'm wrong? |
If your LANGUAGE_CODE is 'en-us' and in your LANGUAGES you have: 'en' and 'de' then django actually supports 3 languages: 'en-us', 'en' and 'de'. The problem is that 'en-us' is not the same as 'en' and it is possible that request.LANGUAGE_CODE becomes 'en-us' if you don't have the language accept headers set. We have 2 possible solutions: Either we add LANGUAGE_CODE to CMS_LANGUAGES as well... and then you can create pages in 'en-us' and 'en' or we enforce that LANGUAGE_CODE is in LANGUAGES. To be honest i think the django docs in this regard should be updated as most people will not understand what is going on in the back and only encounter 500 after they go live and they receive a request without a accept language header and have a new language to deal with for the first time. |
PS. over the years i had soooo many bug reports because of this behavior that i finally decided to enforce the LANGUAGE_CODE in LANGUAGES as it makes absolutely sense in a i18n environment. |
Hi, I just got this nightmare error, but I am still confused how settings.py should be configured. Mine is as follows: LANGUAGE_CODE = 'es-ES' It looks good as long as I access specifying 'Accepted-Language' header either from browser or testing it with curl. BUt wihtout a 'Accepted-Language' header , breaks with 500. What should I tweak?? |
Hi,
but only when I run command I seems that it succeed to index my french pages, but them it makes and error All documents removed. Indexing 534 <django.utils.functional.proxy object at 0x29a0810>. NoReverseMatch: Reverse for 'pages-details-by-slug' with arguments '()' and keyword arguments '{'slug': ''}' not found. in my settings.py LANGUAGE_CODE = 'fr' what is really weird is that is I also add english language in LANGUAGES, eg : LANGUAGES = ( thanks for help |
If a bot like the google bots who does not set the accept_language header is visiting the page without a language prefix and i18n is activated, following error is thrown:
NoReverseMatch: Reverse for 'pages-details-by-slug' with arguments '()' and keyword arguments '{'slug': ''}' not found.
Only happens if DEBUG is False.
The text was updated successfully, but these errors were encountered: