這是我的代碼:如何顯示所有用戶的屬性在Django
def callback(req):
token = req.session.get('token', None)
if not token:
return render_to_response('callback.html', {
'token': True
})
token = oauth.OAuthToken.from_string(token)
if token.key != req.GET.get('oauth_token', 'no-token'):
return render_to_response('callback.html', {
'mismatch': True
})
token = get_authorized_token(token)
# Actually login
obj = is_authorized(token)
if obj is None:
return render_to_response('callback.html', {
'username': True
})
try: user = User.objects.get(username=obj['screen_name'])
except: user = User(username=obj['screen_name'])
user.oauth_token = token.key
user.oauth_token_secret = token.secret
user.save()
req.session['user_id'] = user.id
del req.session['token']
s = ''.join('%s: %s </br>' % (a, getattr(user, a)) for a in dir(user))
return HttpResponse(s)
,我想用
s = ''.join('%s: %s </br>' % (a, getattr(user, a)) for a in dir(user))
return HttpResponse(s)
顯示用戶的屬性,
,但我得到一個錯誤:
AttributeError at /twitter/login/callback/
Manager isn't accessible via User instances
所以我能做什麼,
謝謝