def signup(request, **kwargs):

    form_class = kwargs.pop("form_class", SignupForm)
    template_name = kwargs.pop("template_name", "account/signup.html")
    redirect_field_name = kwargs.pop("redirect_field_name", "next")
    success_url = kwargs.pop("success_url", None)

    group, bridge = group_and_bridge(kwargs)
    ctx = group_context(group, bridge)

    if success_url is None:
        if hasattr(settings, "SIGNUP_REDIRECT_URLNAME"):
            fallback_url = reverse(settings.SIGNUP_REDIRECT_URLNAME)
        else:
            if hasattr(settings, "LOGIN_REDIRECT_URLNAME"):
                fallback_url = reverse(settings.LOGIN_REDIRECT_URLNAME)
            else:
                fallback_url = settings.LOGIN_REDIRECT_URL
        success_url = get_default_redirect(
            request, fallback_url, redirect_field_name)

    if request.method == "POST":
        form = form_class(request.POST, group=group)
        if form.is_valid():
            user = form.save(request=request)
            if settings.ACCOUNT_EMAIL_VERIFICATION:
                ctx.update({
                    "email": form.cleaned_data["email"],
                    "success_url": success_url,
                })
                ctx = RequestContext(request, ctx)
                return render_to_response("account/verification_sent.html",
                                          ctx)
            else:
                form.login(request, user)
                messages.add_message(
                    request, messages.SUCCESS,
                    ugettext("Successfully logged in as %(user)s.") % {
                        "user": user_display(user)
                    })
                return HttpResponseRedirect(success_url)
    else:
        form = form_class(group=group)

    ctx.update({
        "form": form,
        "redirect_field_name": redirect_field_name,
        "redirect_field_value": request.GET.get(
            redirect_field_name,
            request.POST.get(redirect_field_name)),
    })

    return render_to_response(template_name, RequestContext(request, ctx))
dataset/ETHPy150Open amarandon/smeuhsocial/apps/account/views.py/signup/original