我想访问我的模板中的根路径变量,我该怎么做? 到目前为止,我有:django模板:访问项目根路径
{% if user.username == "" and request.path != "/login/" and request.path != "/" %}
<meta http-equiv="REFRESH" content="0;url=/login/">
{% else %}
我想编写这样的事:
{% if user.username == "" and request.path != projectRoot+"/login/" and request.path != projectRoot %}
<meta http-equiv="REFRESH" content="0;url=projectRoot+/login/">
{% else %}
我应该创建并从我的观点发送此projectRoot变量,或者是有已经是一个变量?
提前许多感谢,
罗曼
有没有你想通过这种方式登录重定向一个特别的原因?这样做有很多更好的方法(比如使用['login_required'](https://docs.djangoproject.com/en/dev/topics/auth/default/#the-login-required-decorator)装饰器) – 2013-04-10 09:34:22