Home > Enterprise >  why is the colour of button tag different as you can see in the image?
why is the colour of button tag different as you can see in the image?

Time:04-02

<!DOC TYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Home Page</title>
    </head>
    <body>
        {%for message in messages%}
        <div role="alert">
        <strong>Message:</strong>{{message}}
        <button type="button"  data-dismiss="alert" aria-label="close">
        <span aria-hidden="true">&times;</span>
        </button>
        </div>
        {% endfor %}
    
    
        <h3>Welcome!</h3>
        {%if user.is_authenticated%}
        <h3>hello{{fname}}</h3}       
        <button type="submit"><a href="/signout">signout</a></button>
        {% else %}
        <button type="submit"><a href="/signup">SignUp</a></button>
        <button type="submit"><a href="/signin">SignIn</a></button>
        {% endif%}
    
        
    </body>
    </html>

i am creating a django login form can you tell whats wrong with above code as the signout button is not displayed when i run it

CodePudding user response:

<!DOC TYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Home Page</title>
    </head>
    <body>
        {%for message in messages%}
        <div role="alert">
        <strong>Message:</strong>{{message}}
        <button type="button"  data-dismiss="alert" aria-label="close">
        <span aria-hidden="true">&times;</span>
        </button>
        </div>
        {% endfor %}
    
    
        <h3>Welcome!</h3>
        {%if user.is_authenticated%}
        <h3>hello{{fname}}</h3>}       
        <button type="submit"><a href="/signout">signout</a></button>
        {% else %}
        <button type="submit"><a href="/signup">SignUp</a></button>
        <button type="submit"><a href="/signin">SignIn</a></button>
        {% endif%}
    
        
    </body>
    </html>

There is a typo in the <h3>{hello {{fname}}</h3. You are missing a > in the end h3 tag.

CodePudding user response:

  • Try to name your urls like
path('logout/', views.logout_view, name="logout"),
  • In template it could be used as:
href="{% url 'logout' %}"
<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Home Page</title>
    </head>

    <body>
        
        {% for message in messages %}
            <div  role="alert">
                <strong>Message:</strong>{{message}}
                <button type="button"  data-dismiss="alert" aria-label="close">
                    <span aria-hidden="true">&times;</span>
                </button>
            </div>
        {% endfor %}

        <h3>Welcome!</h3>
        {% if user.is_authenticated %}
            <h3>hello {{ fname }}</h3>
            <!-- Try to not use hard urls like /signout -->
            <!-- Instead use {% url 'urlname' %} -->
            <button type="submit"><a href="/signout">signout</a></button>
        {% else %}
            <button type="submit"><a href="/signup">SignUp</a></button>
            <button type="submit"><a href="/signin">SignIn</a></button>
        {% endif%}
    </body>

</html>
  • Related