简体   繁体   English

Django 动态模板与自定义 function 问题

[英]Django Dynamic Template with Custom function problem

As I have using the django custom table for authentication and session id for setting the navbar action but not able to change with custom function able to find similar things but how i can write my custom function pls find As I have using the django custom table for authentication and session id for setting the navbar action but not able to change with custom function able to find similar things but how i can write my custom function pls find

Code for userauth inbuilt management which i intent to change user.authenticated to a custom function userauth 内置管理的代码,我打算将 user.authenticated 更改为自定义 function

{% if user.is_authenticated %}
          {{user.username}}
          <li><a href="/logout">Logout</a></li>
{% else %}
 <li><a href="/login">Login/a></li>
 <li><a href="/register">Register</a></li>
{% endif %}
**                    {% if request.session.member_id %}
                            <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                {{request.session.member_id}}
                    </a>
                    <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="{% url 'myaccount' %}">My Profile</a>
                    <a class="dropdown-item" href="{% url 'logout' %}">Sign Out</a>
--> Guest Login–>--> --> --> 访客登录-->--> -->
 {% else %} <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> My Account </a> <div class="dropdown-menu" aria-labelledby="navbarDropdown"> <a class="dropdown-item" href="{% url 'login' %}">Login</a> <a class="dropdown-item" href="{% url 'registration' %}">Sign Up</a> {% endif %}

I am Using session Id for verification is it safe for use??我正在使用 session Id 进行验证是否可以安全使用?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM