> For the complete documentation index, see [llms.txt](https://sathyakumars-kb.gitbook.io/user-authentication-based-django-app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://sathyakumars-kb.gitbook.io/user-authentication-based-django-app/todo-app/demo-workflow-of-todo-app.md).

# DEMO: Workflow of Todo App

Demonstrating the workflow for Todo App

## <mark style="color:green;">Note</mark>

<mark style="background-color:green;">**This documentation outlines the key steps in creating a ToDo app using Django, including**</mark>**&#x20;**<mark style="color:red;background-color:green;">**defining URL patterns**</mark><mark style="background-color:green;">**,**</mark>**&#x20;**<mark style="color:red;background-color:green;">**creating views**</mark>**&#x20;**<mark style="background-color:green;">**to handle logic, and**</mark>**&#x20;**<mark style="color:red;background-color:green;">**developing templates**</mark>**&#x20;**<mark style="background-color:green;">**for user interface presentation.**</mark>

## Step &#x31;**. Develop Templates:**

**create `templates/todo folder`**

Create HTML templates to define the structure and layout of your ToDo app's pages. Templates are used by views to generate dynamic content that is sent to the user's browser.

save main.html in templates/todo folder

`main.html`:

```html
<!-- Example main.html -->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    {% block content %}

    {%endblock content%}
</body>
</html>
```

save task.html in templates/todo folder

`task.html`:

```html
<!-- Example task.html -->

{% extends 'todo/main.html' %}

{% block content %}
<h1>Task List</h1>

{% for task in tasks%}
<h3>{{task}}</h3>
{% endfor%}

{% endblock content %}
```

## Step 2. Mapping URLs to views **(urls.py):**

Begin by establishing the URL patterns for your Todo app. This involves mapping specific URLs to corresponding views that will handle the user's requests.

```python
# Example urls.py

from django.urls import path
from . import views

urlpatterns = [
    path('tasks', views.Tasks_list.as_view(), name='tasks'),
    # Add more URL patterns as needed
]
```

## **Step 3. Create Views (views.py):**

Develop the views that will handle the logic for different parts of your ToDo app. Views are responsible for processing user requests, interacting with the data model, and rendering templates.

```python
from django.views.generic.list import ListView

class Tasks_list(ListView):
    model = Task
    template_name = 'todo/task.html'
    context_object_name = 'tasks'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['tasks'] = context['tasks'].filter(user=self.request.user)
        return context
```

Here's a breakdown of how this works:

1. `self.request.user`: This assumes that you are inside a Django class-based view or a middleware where `self.request` is an instance of the `HttpRequest` object, and `user` is the user associated with the request.
2. `context['tasks']`: This suggests that you are working with a context dictionary, commonly used in Django views to pass data to templates.
3. `context['tasks'].filter(...)`: It implies that `context['tasks']` is a queryset, likely a model queryset, on which you want to apply a filter.
4. `.filter(user=self.request.user)`: This is filtering the queryset to include only those records where the `user` field is equal to the `self.request.user`. This is a common pattern to filter objects based on the currently logged-in user.

## **Step 4: Run the development server to check the functionality:**

Start the development server if it's not running already:

```
python manage.py runserver
```

Access the interface by visiting `http://localhost:8000/tasks` in your web browser.
