According to Arthur, this is well documented in the Django documentation.
This is actually pretty simple:
from django.db import models class Person(models.Model):
As you can see, you simply create the foreign key in the person → class, which is pretty much the same as how you manually configured it in the database, if you do.
Django will automatically add an inverse relationship so you can find people from the group:
some_group.people
Note that related_name indicates the name of the inverse relationship. This is optional, but I think you want to use people instead of persons .
source share