'Is this many to one relation case?

I would like to ask for a suggestion on how to aproach this use case. I have a list of projects and each project has it's own parts list with different parts. So it is many-to-one relation, correct?

How can I display parts lists in Admin grouped by project, so after clicking on Parts list, I can see Projects names and after clicking on asome project name, I can see list of all items (parts) from particular parts list?

And how can I create table with all items? This doesn't seems to work...

<tr>
{% for part in partslist %}
<td class="align-middle">{{ part.item}}</td>
<td class="align-middle">{{ part.description }}</td>
<td class="align-middle">{{ part.qty }}</td>
{% endfor %}
</tr>

Or is this wrong approach?

Thank you.

class Project(models.Model):
    project_name = models.CharField(max_length=100, null=False, blank=False)
    created = models.DateTimeField(auto_now_add=True)

    def __str__(self):
        return self.project_name
class PartsList(models.Model):
    item = models.IntegerField()
    description = models.CharField(max_length=100)
    qty = models.IntegerField()
    project = models.ForeignKey(Project, on_delete=models.CASCADE)

    def __str__(self):
        return str(self.project)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source