개인 센터 홈 페이지

6995 단어 django

#   
def mine(request):

    #       
    title = '  '
    usericon = ''

    #   session  ,
    username = request.session.get('username')

    #       
    if username == None:
        username = '   '
        #    ,    ,    
        is_login = False
    else:
        is_login = True
        #            
        user = User.objects.get(u_name=username)
        #     ,    
        usericon = "http://127.0.0.1:8000/static/uploadfiles/" + user.u_icon.url

    context = {
        'title':title,
        'is_login':is_login,
        'username':username,
        'usericon':usericon,
    }
    return render(request, 'axf/mine/mine.html',context=context)



{#      (  )    is_login true  false,             #}
{% if is_login %}
    <img id="user_icon" src="{{ usericon }}" alt="">
{% else %}
    <span class="glyphicon glyphicon-user">span>
{% endif %}

{#           ,             #}
{% if is_login %}
    <p><a href="{% url 'axf:userInfoMod' %}">{{ username }}a>p>
{% else %}
    <p><a href="{% url 'axf:login' %}">{{ username }}a>p>
{% endif %}
    <p><span class="glyphicon glyphicon-fire">span><span>  span>p>

{#        ,          #}
{% if is_login %}
{% else %}
    <a id="regis" href="{% url 'axf:register' %}">  a>
{% endif %}



{#      ,       ,         #}
{% if is_login %}
    <p><a href="{% url 'axf:logout' %}">      a>p>
{% endif %}

좋은 웹페이지 즐겨찾기