I have a UserProfile
model for each user that has a many to many relationship with another Team
model to store a list of teams that each member belongs to.
class Team(models.Model):
team_name = models.CharField(max_length=200)
organization_name = models.CharField(max_length=200)
def __unicode__(self):
return self.organization_name
class UserProfile(models.Model):
user = models.OneToOneField(User, unique=True, related_name='profile')
team = models.ManyToManyField(Team)
I want to create a form which includes a team field that would allow the user to select from a list teams that are filtered to only allow that user to pick teams which they belong to by relation.
I'm confused as to how to approach this, but I'm assuming it would be some sort of filtered queryset?