def follow_unfollow(request, content_type_id, object_id, flag, do_follow=True, actor_only=True):
    """
    Creates or deletes the follow relationship between ``request.user`` and the
    actor defined by ``content_type_id``, ``object_id``.
    """
    ctype = get_object_or_404(ContentType, pk=content_type_id)
    instance = get_object_or_404(ctype.model_class(), pk=object_id)

    # If flag was omitted in url, None will pass to flag keyword argument
    flag = flag or ''

    if do_follow:
        actions.follow(request.user, instance, actor_only=actor_only, flag=flag)
        return respond(request, 201)   # CREATED

    actions.unfollow(request.user, instance, flag=flag)
    return respond(request, 204)
Creates or deletes the follow relationship between ``request.user`` and the
    actor defined by ``content_type_id``, ``object_id``.