我是Django / Python的新手,我无法检索user
属性,例如first_name
。我错过了什么?
class principal(LoginRequiredMixin, TemplateView):
template_name = 'appPortal/index.html'
def get_context_data(self, **kwargs):
usuario = self.request.user
context = super().get_context_data(**kwargs)
print (usuario) ### OK, returns the logged user
print (usuario.first_name) ### Don't work, returns nothing
print (usuario.get_short_name()) ### Don't work too
### The code continues, but the last two print() don't work
谢谢,
答案 0 :(得分:0)
确保您不允许将必填字段留空!