Skip to content

Instantly share code, notes, and snippets.

@Tobiaqs
Last active March 17, 2022 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tobiaqs/8ce8e3c88e0e313afeb7f4b96c5bffdc to your computer and use it in GitHub Desktop.
Save Tobiaqs/8ce8e3c88e0e313afeb7f4b96c5bffdc to your computer and use it in GitHub Desktop.
Django-channels, deal with accept-language
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