def METHOD_NAME(request):
    context = {}
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            data = form.cleaned_data
            # create inactive user
            user = auth.models.User.objects.create_user(
                data['username'], data['email'], data['password']
            )
            user.is_active = False
            user.first_name = data.get('first_name', '')
            user.last_name = data.get('last_name', '')
            user.save()
            # create confirmation
            conf = EmailConfirmation(
                type='registration', user=user, email=user.email
            )
            conf.save()
            context['confirmation'] = conf
            # send email
            subject = render_to_string(
                'patchwork/mails/activation-subject.txt'
            )
            message = render_to_string(
                'patchwork/mails/activation.txt',
                {'site': Site.objects.get_current(), 'confirmation': conf},
            )
            try:
                send_mail(
                    subject, message, settings.DEFAULT_FROM_EMAIL, [conf.email]
                )
            except smtplib.SMTPException:
                context['confirmation'] = None
                context['error'] = (
                    'An error occurred during registration. '
                    'Please try again later'
                )
    else:
        form = RegistrationForm()
    context['form'] = form
    return render(request, 'patchwork/registration.html', context)