2011-08-07 3 views
0

사용자가 로그인했을 때 'Hello, John'이라고 말하도록 내 사이트를 얻는 방법을 알아 냈습니다. 그러나 오류를 반환하지 않는 방법을 알아낼 수 없습니다.web2py - 형식을 매핑해야합니까?

<type 'exceptions.TypeError'>(format requires a mapping) 

이 코드 :

return dict(listings=listings, hello='hello %(first_name)s' % auth.user) 

답변

1

아마도 당신의 auth.user 여기

None가 그 예외

를 던질 것이라고 빠른 검사입니다

당신은이 완벽하게 작동이

hello = 'hello %(first_name)s %s' % auth.user if auth.user else '' 
return dict(listings=listings, hello=hello) 
+0

처럼 뭔가를해야만 시도해 볼 수도 있습니다, 감사합니다! – Jarrod