Last active
March 17, 2022 11:19
-
-
Save Tobiaqs/8ce8e3c88e0e313afeb7f4b96c5bffdc to your computer and use it in GitHub Desktop.
Django-channels, deal with accept-language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def connect(self): | |
class dummy_request: | |
COOKIES = {} | |
META = {'HTTP_ACCEPT_LANGUAGE': dict(self.scope['headers']).get('accept-language'.encode('utf-8'), bytes()).decode('utf-8')} | |
translation.activate(translation.get_language_from_request(dummy_request)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment