user.u是否经过身份验证不从事生产

2024-04-25 19:11:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用的是django1.11.5版本,在我的模板中{{ user.is_authenticated }}正在打印CallableBool(False)CallableBool(True)

这让我的模版条件很混乱

{% if not user.is_authenticated %}

https://code.djangoproject.com/ticket/26988我在django项目网站上看到过这个问题,它说要升级到django版本1.10,但我的django版本是1.11.5

我的python版本是3.5 我想我得到的不是bool值true或false,而是CallableBool,它是类型,并且混淆了我的条件user.is_authenticated

你知道吗视图.py你知道吗

class LandingView(TemplateView):
    template_name = "website/landing.html"

    def get_context_data(self, **kwargs):
        context = super(LandingView, self).get_context_data(**kwargs)
        print(User)
        church_id = self.request.session.get('church_id', None)
        print(church_id)
        if church_id:
            samples = ObituarySample.objects.filter(organization__id=church_id)
            context['obituary_samples'] = samples

            recent_obituaries = Obituary.objects.filter(organization__id=church_id).order_by("-id")[:3]
            context['recent_obituaries'] = recent_obituaries

        context['church_cover'] = self.request.session.get('church_cover', None)
        return context

Tags: djangoself版本idgetiscontext条件