[問題] django view and templates

看板Python作者 (.)時間9年前 (2016/03/14 23:10), 編輯推噓1(103)
留言4則, 2人參與, 最新討論串1/1
tutorial https://thinkster.io/django-angularjs-tutorial github https://github.com/brwr/thinkster-django-angular 在templates/navbar.html裡面 他用變數user.is_authenticated 來切換navbar按鈕 請問在authentication/view.py 裡面 他是如何產生變數 user 並且放在context然後return response? 我隱約覺得這跟django built-in authentication User Class有關聯 但是卻不清楚template裡面的user是怎麼從view.py傳出來的 謝謝大家解答 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 204.96.168.3 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1457997041.A.BE8.html

03/15 08:55, , 1F
https://goo.gl/SdFxMp request.user.is_authenticated()
03/15 08:55, 1F

03/15 08:56, , 2F
django.short.render(request,template_name,dictionary)
03/15 08:56, 2F

03/15 14:58, , 3F
來自 django.contrib.auth.context_processors.auth
03/15 14:58, 3F

03/15 14:59, , 4F
這個叫 context processor, 詳細解釋請參照文件
03/15 14:59, 4F
文章代碼(AID): #1MvqJnle (Python)