code: def authenticated_userid(request):
      
      user = getattr(request, 'user', None)
      key = user.pk_field()
      return getattr(user, key)
docs: Helper function that can be used in ``db_key`` to support `self`
      as a collection key.