-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix 262 tests #277
base: main
Are you sure you want to change the base?
Fix 262 tests #277
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I guess we need to take a step back and actually think about what the requirements are
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments in middleware
No description provided.