Always including the user in the django template context

前端 未结 8 648
一向
一向 2020-12-04 14:22

I am working on a small intranet site for a small company, where user should be able to post. I have imagined a very simple authentication mechanism where people just enter

8条回答
  •  旧时难觅i
    2020-12-04 15:02

    If you can hook your authentication into the Django authentication scheme you'll be able to use request.user.

    I think this should just be a case of calling authenticate() and login() based on the contents of your Cookie.

    Edit: @Staale - I always use the locals() trick for my context so all my templates can see request and so request.user. If you're not then I guess it wouldn't be so straightforward.

提交回复
热议问题