Conversation
…o that we have access to the url resolver. Then check if the requested path belongs to i18n_patterns.
2e602a5 to
373d83b
Compare
373d83b to
335e2b4
Compare
|
@saevarom Can you have a look at this one? |
| if ( | ||
| request.path == "/" | ||
| or request.resolver_match | ||
| and pattern.match(request.resolver_match.route) | ||
| ): | ||
| try: | ||
| HomePage.objects.get(locale__language_code=get_language(), live=True) | ||
| response = self.get_response(request) | ||
| except HomePage.DoesNotExist: | ||
| # The requested language is not available, use the default | ||
| activate(settings.LANGUAGE_CODE) | ||
| response = self.get_response(request) | ||
| else: | ||
| response = self.get_response(request) |
There was a problem hiding this comment.
If you call the resolver before get_response you will always have None, so this code defaults to the else statement every single time. I ran the tests with a print statement in the else section and it printed every time.
I also tried to set my language to a language that had a matching homepage and it did not properly set my preferred language until I put the response = self.get_response(request) at the top.
I see that you removed the 404 response when a language does not exist, was there a reason for that?
There was a problem hiding this comment.
I'm not sure why the tests do not fail on the language preference, but at least it was not working in the browser for me
There was a problem hiding this comment.
I think that the tests that correctly pass when a user asks for "/" and is redirected to the preferred language (browser or cookie) because of LocaleMiddleware
There was a problem hiding this comment.
So, I guess we need to take a step back and actually think about what the requirements are
saevarom
left a comment
There was a problem hiding this comment.
See comments in middleware
No description provided.