def twitter_login(request, redirect_field_name='next'):
    # construct the callback URL
    try:
        protocol      = 'https' if request.is_secure() else 'http'
        host          = request.get_host()
        path          = reverse('twitter-callback')
        callback_url  = protocol + '://' + host + path
    except NoReverseMatch:
        callback_url  = None
    
    # get a request token from Twitter
    consumer      = oauth.Consumer(settings.KEY, settings.SECRET)
    request_token = oauth.RequestToken(consumer, callback_url=callback_url)
    
    # save the redirect destination
    request.session['redirect_to'] = request.REQUEST.get(redirect_field_name, None)
    
    # redirect to Twitter for authorization
    return HttpResponseRedirect(request_token.authorization_url)
dataset/ETHPy150Open mdiep/django-twitter-users/twitter_users/views.py/twitter_login/original