original_docstring: 
          Copypasted from tastypie, modified to avoid issues with app-loading and
          custom user model.
          
docstring: Copypasted from tastypie, modified to avoid issues with app-loading and
  custom user model.
docstring_tokens: Copypasted from tastypie modified to avoid issues with app - loading and custom user model .
code: def is_authenticated(self, request, **kwargs):
          """
          Copypasted from tastypie, modified to avoid issues with app-loading and
          custom user model.
          """
          User = get_user_model()
          username_field = User.USERNAME_FIELD
  
          try:
              username, api_key = self.extract_credentials(request)
          except ValueError:
              return self._unauthorized()
  
          if not username or not api_key:
              return self._unauthorized()
  
          try:
              lookup_kwargs = {username_field: username}
              user = User.objects.get(**lookup_kwargs)
          except (User.DoesNotExist, User.MultipleObjectsReturned):
              return self._unauthorized()
  
          if not self.check_active(user):
              return False
  
          key_auth_check = self.get_key(user, api_key)
          if key_auth_check and not isinstance(key_auth_check, HttpUnauthorized):
              request.user = user
  
          return key_auth_check
code_tokens: def is_authenticated ( self , request , ** kwargs ) : User = get_user_model ( ) username_field = User . USERNAME_FIELD try : username , api_key = self . extract_credentials ( request ) except ValueError : return self . _unauthorized ( ) if not username or not api_key : return self . _unauthorized ( ) try : lookup_kwargs = { username_field : username } user = User . objects . get ( ** lookup_kwargs ) except ( User . DoesNotExist , User . MultipleObjectsReturned ) : return self . _unauthorized ( ) if not self . check_active ( user ) : return False key_auth_check = self . get_key ( user , api_key ) if key_auth_check and not isinstance ( key_auth_check , HttpUnauthorized ) : request . user = user return key_auth_check
short_docstring: Copypasted from tastypie, modified to avoid issues with app-loading and
  custom user model.
short_docstring_tokens: Copypasted from tastypie modified to avoid issues with app - loading and custom user model .
comment: """
          Copypasted from tastypie, modified to avoid issues with app-loading and
          custom user model.
          """