title: SynchronousOnlyOperation Error in with django 3 and django channels
body: <p>I had a django 2 app and i used django channels for socket connection.</p>
  
  <p>i just update django to version 3. and now daphne show this error when i try to make a socket connection. i had not any problem with django 2.</p>
  
  <pre><code>[Failure instance: Traceback: &lt;class 'django.core.exceptions.SynchronousOnlyOperation'&gt;: You cannot call this from an async context - use a thread or sync_to_async.
  /home/ubuntu/pl_env/lib/python3.6/site-packages/autobahn/websocket/protocol.py:2844:processHandshake
  /home/ubuntu/pl_env/lib/python3.6/site-packages/txaio/tx.py:429:as_future
  /home/ubuntu/pl_env/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred
  /home/ubuntu/pl_env/lib/python3.6/site-packages/daphne/ws_protocol.py:83:onConnect
  --- &lt;exception caught here&gt; ---
  /home/ubuntu/pl_env/lib/python3.6/site-packages/twisted/internet/defer.py:151:maybeDeferred
  /home/ubuntu/pl_env/lib/python3.6/site-packages/daphne/server.py:201:create_application
  /home/ubuntu/pl_env/lib/python3.6/site-packages/channels/routing.py:54:__call__
  /home/ubuntu/pl_env/lib/python3.6/site-packages/channels/security/websocket.py:37:__call__
  /home/ubuntu/petroline_django/orders/token_auth.py:25:__call__
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/manager.py:82:manager_method
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/query.py:411:get
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/query.py:258:__len__
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/query.py:1261:_fetch_all
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/query.py:57:__iter__
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/db/models/sql/compiler.py:1142:execute_sql
  /home/ubuntu/pl_env/lib/python3.6/site-packages/django/utils/asyncio.py:24:inner
  </code></pre>
  
  <p>it says the problem is in token_auth.py, line 25. this line is <code>token = Token.objects.get(key=token_key)</code></p>
  
  <p>this is my token_auth.py that handles token authentication. </p>
  
  <pre><code>from channels.auth import AuthMiddlewareStack
  from django.contrib.auth.models import AnonymousUser
  from django.db import close_old_connections
  from rest_framework.authtoken.models import Token
  
  
  class TokenAuthMiddleware:
      """
      Token authorization middleware for Django Channels 2
      see:
      https://channels.readthedocs.io/en/latest/topics/authentication.html#custom-authentication
      """
  
      def __init__(self, inner):
          self.inner = inner
  
      def __call__(self, scope):
          headers = dict(scope['headers'])
          if b'authorization' in headers:
              try:
                  token_name, token_key = headers[b'authorization'].decode().split()
                  if token_name == 'Token':
                      # Close old database connections to prevent usage of timed out connections
                      close_old_connections()
                      token = Token.objects.get(key=token_key)
                      scope['user'] = token.user
              except Token.DoesNotExist:
                  scope['user'] = AnonymousUser()
          return self.inner(scope)
  
  TokenAuthMiddlewareStack = lambda inner: TokenAuthMiddleware(AuthMiddlewareStack(inner))
  </code></pre>