Using foreign key to link two models, info is being duplicated on template

I have been building a project for the first time ever! I am super excited however, I am running into an issue. Which I am not experienced enough to troubleshoot on my own right now.
I have an “Award” model and a “Status” model. The Status is linked to the Award model so users can make a comment on the award and it records the date, the user who made the comment and what the comment says. On the admin page, I created 2 awards and 2 comments, both comments are linked to award #1. When looking at the template (html) it is showing the comments for both awards. Additionally, I would like to just display the most recent comment on the main table, allowing the user to click a link for more info and a list of all the comments for that award.

from django.db import models
from django.contrib.auth.models import User

# Create your models here.
     ('other', 'Other')

            ('E4-3', 'CPL'),
            ('E5', 'SGT'),
            ('E6', 'SSG'),
            ('E7', 'SFC'),
            ('E8', 'MSG'),
            ('E8-2', '1SG'),
            ('E9', 'SGM'),
            ('E9-2', 'CSM'),
            ('E9-3', 'SMA'),
            ('WO1', 'WO1'),
            ('CW2', 'CW2'),
            ('CW3', 'CW3'),
            ('CW4', 'CW4'),
            ('CW5', 'CW5'),
            ('2LT', '2LT'),
            ('1LT', '1LT'),
            ('CPT', 'CPT'),
            ('MAJ', 'MAJ'),
            ('LTC', 'LTC'),
            ('COL', 'COL'),
            ('BG', 'BG'),
            ('MG', 'MG'),
            ('LTG', 'LTG'),
            ('GEN', 'GEN'),
            ('GA', 'GA'),
    ('other', 'Other')

    ('AAM', 'AAM'),
    ('ARCOM', 'ARCOM'),
    ('MSM', 'MSM'),
    ('LOM', 'LOM'),
    ('OTHER', 'Other')

    ('ACH', 'ACH'),
    ('SVC', 'SVC'),
    ('PCS', 'PCS'),
    ('ETS', 'ETS'),
    ('RET', 'RET'),
    ('HER', 'HEROISM'),
    ('VAL', 'VALOR'),
    ('OTH', 'Other'),

class Award(models.Model):
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    first_name = models.CharField(max_length=50, verbose_name = "First Name")
    last_name = models.CharField(max_length=50, verbose_name = "Last Name")
    rank = models.CharField(max_length=5, default=None, 
    unit = models.CharField(max_length=6, default=None, 
    recommended_award = models.CharField(max_length=5, default=None,
        choices=RECOMMENDED_AWARD, verbose_name = "Recommended Award")
    award_reason = models.CharField(max_length=3, default=None,
        choices=AWARD_REASON, verbose_name = "Award Reason")
    date_received = models.DateField(blank=True, null=True, default=None,
        verbose_name = "Date Received")
    presentation_date = models.DateField(blank=True, null=True, default=None,
        verbose_name = "Presentation Date")
    letter_of_lateness = models.BooleanField(blank=True, null=True,
        default=None, verbose_name = "Letter of Lateness Required?")
    date_sent_higher = models.DateField(blank=True, null=True, default=None,
        verbose_name = "Date Submitted to Higher")
    submitted_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL)

    def __str__(self):
        return self.last_name + ', ' + self.first_name + ' ' + str(self.date_created)[:10]
class Status(models.Model):
    date_created = models.DateTimeField(auto_now_add=True)
    date_modified = models.DateTimeField(auto_now=True)
    status_comment = models.TextField(max_length=200)
    award_link = models.ForeignKey(Award, null=False, 
    submitted_by = models.ForeignKey(User, null=True, on_delete=models.SET_NULL)
    class Meta:
        verbose_name_plural = "Statuses"

    def __str__(self):
        return self.status_comment

from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages

from .forms import RegisterForm
from .models import Award
from .models import Status

# Create your views here.
def home(request):

    awards = Award.objects.all()
    status = Status.objects.all()

    context = {

    #Check if logging in
    if request.method == 'POST':
        username = request.POST['username']
        password = request.POST['password']

        # Authenticate
        user = authenticate(request, username=username, password=password)
        if user is not None:
            login(request, user)
            messages.success(request, "Login Successful.")
            return redirect('home')
            messages.error(request, "ERROR: Login unsuccessful. Try again or contact site administrator.")
            return redirect('home')
        return render(request, 'home.html', context)

def logout_user(request):
    messages.success(request, "You have been successfully logged out.")

    return redirect('home')

def register_user(request):
    if request.method == 'POST':
        form = RegisterForm(request.POST)

        if form.is_valid():
            # Auth and Login
            username = form.cleaned_data['username']
            password = form.cleaned_data['password1']
            user = authenticate(username=username, password=password)
            login(request, user)
            messages.success(request, "You have successfully registered.")
            return redirect('home')
        form = RegisterForm()
        return render(request, 'register.html', {'form':form})
    return render(request, 'register.html', {'form':form})


{% if user.is_authenticated %}
<div class="container">
    {% if not awards.all %}
        <h1>No Awards Present.</h1>
    {% else %}
        <table class="table table-hover text-center">
            <thead class="text-center text-wrap">
                    <th scope="col">Unit</th>
                    <th scope="col">Rank</th>
                    <th scope="col">Name</th>
                    <th scope="col">Award Type</th>
                    <th scope="col">Reason</th>
                    <th scope="col">Date Received</th>
                    <th scope="col">Presentation Date</th>
                    <th scope="col">LoL Required</th>
                    <th scope="col">Date to Higher</th>
                    <th scope="col">Status Date</th>
                    <th scope="col">Current Status</th>
                    <th scope="col">User</th>

                {% if awards %}
                    {% if status %}
                        {% for stat in status %}
                            {% for award in awards %}
                                        <td style="width: 8rem;">{{ award.unit }}</td>
                                        <td style="width: 5rem;">{{ award.rank }}</td>
                                        <td><a href="">{{ award.last_name|title }}, {{ award.first_name|title }}</a></td>
                                        <td>{{ award.recommended_award }}</td>
                                        <td>{{ award.award_reason }}</td>

                                        {% if award.date_received == None %}
                                        {% else %}
                                            <td>{{ award.date_received }}</td>
                                        {% endif %}

                                        {% if award.presentation_date == None %}
                                        {% else %}
                                            <td>{{ award.presentation_date }}</td>
                                        {% endif %}

                                        {% if award.letter_of_lateness == None %}
                                        {% else %}
                                            <td>{{ award.letter_of_lateness }}</td>
                                        {% endif %}
                                        {% if award.date_sent_higher == None %}
                                        {% else %}
                                            <td>{{ award.date_sent_higher }}</td>
                                        {% endif %}
                                        <td style="width: 5rem;">{{ stat.date_modified }}</td>
                                        <td class="text-start">{{ stat.status_comment }}</td>
                                        <td class="text-start">{{ stat.submitted_by|title }}</td>
                                {% endfor %}
                            {% endfor %}
                    {% endif %}
                {% endif %}
    {% endif %}
{% endif %}```

The set of Status related to an Award is referenced by the related name of the ForeignKey field. (See the docs at Related objects reference | Django documentation | Django)

In this specific case, if you have an instance of Award named an_award, then the set of Status related to an_award is an_award.status_set.all() (or an_award.status_set.all if you’re referencing this function in a template).

Since an_award.status_set is a reference to a manager (see link above), you also have the ability to sort or filter that queryset provided by that manager.

Thank you for the reply.

As I am still new to this, would this be a query in my

Or a reference to that in your template - that’s why i showed the two different versions. You have a choice either way.

I still seem to be having an issue understanding.

Can you be more specific about what’s still a question in your mind? I’d like to try to help clear this up.

For some reason, if I remove one of the nest for loops the entries are no longer duplicated on ALL entries.

{% if awards %}
              {% for status in status %}
                            {% for award in awards %}
                            {% endfor %}
             {% endfor %}
{% endif %}

Its taking the status thats attached to one award, and its looping them onto each. I would just like the most recent status to be displayed in the column titled “Current Status” and the date the status was posted in column titled “Status Date”

*If you look at the screenshot, one of the status’ is “Status comment #1 for PVT Jane, Doe” however, it shows that comment for all people.