DEV Community

Phansivang
Phansivang

Posted on

Django Redirect to home page if User is try to go login Page (If user is authenticated)

login.html

{% block content %}
    {% if user.is_authenticated %}
        <meta http-equiv="REFRESH" content="0;url=/">
    {% else %}
        <form method="POST">
    {% csrf_token %}
    {{ form|crispy }}
    <button type="submit" class="btn btn-outline-info">LOGIN</button>
        <a href="{% url 'register' %}">SIGN UP</a>
    </form>
    {% endif %}
{% endblock %}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)