Hi all!
New in Django, and confused, help is appreciated! I'm trying to create a table, like:
| Organization | Total amount of appeals | Amount of written form appeals | Amount of oral form appeals |
|---|---|---|---|
| Organization 1 | 3 | 1 | 2 |
| Organization 2 | 2 | 1 | 1 |
Have three models:
class Organization(models.Model):
organization_name = models.CharField(max_length=50)
class AppealForm(models.Model):
form_name = models.CharField(max_length=50)
class Appeal(models.Model):
organization = models.ForeignKey(Organization, on_delete=models.CASCADE)
appeal_form = models.ForeignKey(AppealForm, on_delete=models.CASCADE)
applicant_name = models.CharField(max_length=150)
Objects of Organization model:
| organization_name |
|---|
| Organization 1 |
| Organization 2 |
Objects of AppealForm model:
| form_name |
|---|
| In written form |
| In oral form |
Objects of Appeal model:
| organization | appeal_form | applicant_name |
|---|---|---|
| Organization 1 | In written form | First and Last name |
| Organization 1 | In oral form | First and Last name |
| Organization 1 | In oral form | First and Last name |
| Organization 2 | In written form | First and Last name |
| Organization 2 | In oral form | First and Last name |
How to make a complex query, to retrieve info from Appeal model? And place to exact fields of the table above?:(
