Django.fun

Django how to display model objects in HTML

This pic shows how it looks now Hi,I'm new to Django, I have a question here, it would be great if anyone can help. I have a table in Django, there are team and task in the table, I want to display all the tasks under a team in HTML. Now I can only display all task and all team together, I can't display them in a well-classified way. Is it the tamplate tags in the assign.html that I need to make some changes? Please give me some hints, thanks in advance.

models.py

''' class Todo(models.Model):

status_option = (
    ('to_do', 'to_do'),
    ('in_progress', 'in_progress'),
    ('done', 'done'),
)
status = models.CharField(max_length=20, choices=status_option, default='to_do')
# todo_list's content
team = models.ForeignKey('Team', on_delete=models.CASCADE)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
name = models.CharField(max_length=20)
create_date = models.DateTimeField(auto_now_add=True)
start_date = models.DateTimeField(default=datetime.datetime.now)
due_date = models.DateTimeField(default=datetime.datetime.now)

project_code = models.CharField(max_length=20)
details = models.TextField()

def __str__(self):
    return self.status
    # return self.team['team'].queryset

def update_status(self):
    if self.status == 'to_do':
        self.status = 'in_progress'
    elif self.status == 'in_progress':
        self.status = 'done'
    self.save()


class Team(models.Model):
name = models.CharField(max_length=20)
employeeID = models.CharField(max_length=20)

email = models.CharField(max_length=50)
position = models.CharField(max_length=50)
password = models.CharField(max_length=20)
projects = models.ForeignKey(Project, on_delete=models.CASCADE)

def __str__(self):
    return self.name

'''

views.py

'''

def assign(request):
team = Team.objects.all()
todos = Todo.objects.all().order_by('team')
# progresses = team.todo_set.filter(status='in_progress')
# dones = team.todo_set.filter(status='done')
context = {'todos': todos, 'team': team}
return render(request, 'todo_lists/assign.html', context)

'''

assign.html

'''

<!doctype html>
{% extends "todo_lists/base.html" %}

{% block assignpage %}
{% load static %}

  <p>Projects</p>


  <div class="card" style="width: 25rem;">
    <div class="innerbox">
  
       <p class="card-title"><a href="{% url 'todo_lists:assign'%}">{{ team.name }}</a></p>
    {% for todo in todos %}  
      
        <p class="card-title"><a href="{% url 'todo_lists:assign'%}">{{ todo.team }}</a></p>
        <div class="inner">
        <p>details: {{ todo.name }}</p>
          <p>Status:{{ todo.status }}</p>
          <p>{{ todo.create_date }}</p>
          <p>{{ todo.due_date }}</p>
        </div>
                  
      {% empty %}
        <li>No project has been added yet.</li>
      {% endfor %} 
     
    </div>
  </div>
[![enter image description here][1]][1]{% endblock %}

Answers: 0