Task List User Authentication
1. Create template for TaskList module.
{% extends 'todo/main.html' %} {% block content %}
<div class="header-bar">
<div>
<h1>Hello {{request.user|title}}</h1>
<h3 style="margin:0">You have <i>{{count}}</i> incomplete task{{ count|pluralize:"s" }}</h3>
</div>
{% if request.user.is_authenticated %}
<a href="">Logout</a> {% else %}
<a href="{% url 'login' %}">Login</a> {% endif %}
</div>
<div id="search-add-wrapper">
{% if tasks|length > 0 %}
<a id="add-link" href="">+</a>
{% endif %}
</div>
<div id="tasklist" class="task-items-wrapper">
{% for task in tasks %}
<div class="task-wrapper" data-position="{{task.pk}}">
<div class="task-title">
{% if task.complete %}
<div class="task-complete-icon"></div>
<i><s><a href="">{{task}}</a></s></i> {% else %}
<div class="task-incomplete-icon"></div>
<a href="">{{task}}</a> {% endif %}
</div>
<div class="task-controls">
<a class="delete-link" href="">×</a>
<span class="handle"> ⠇</span>
</div>
</div>
{% empty %}
<div style="text-align: center; padding-bottom: 10px; line-height: 1em;">
<h3>No new tasks are created.</h3>
<h3>Create a <a style="text-decoration: none; color: #e53935;" href="">New task</a> ! </h3>
</div>
{% endfor %}
</div>
{% endblock content %} 2. Create view function for TaskList Module.
Remove the home view function and replace with below TaskList View
3. Mapping URLs to login view.
Remove the home url and replace with below TaskList url
4. Run the development server to check the functionality:
Output:


Last updated