def METHOD_NAME(self, request, *args, **kwargs):
    realm = get_object_or_404(Realm, pk=kwargs["pk"])
    callback = "realms.utils.test_callback"
    callback_kwargs = {}
    redirect_url = None
    try:
        redirect_url = realm.backend_instance.initialize_session(request, callback, **callback_kwargs)
    except Exception:
        logger.exception("Could not get realm %s redirect URL", realm.pk)
    if redirect_url:
        return HttpResponseRedirect(redirect_url)
    else:
        messages.error(request, "Configuration error")
        return HttpResponseRedirect(realm.get_absolute_url())