[Fixed]-Simplest way for users to add themselves to a "team" in Django


If you wanted to allow users to join a team, I’d have a team attribute on the user model that was a FK to the Team.

Then in a form, you could define the list of available teams as you’ve suggested;

team = forms.ModelMultipleChoiceField(queryset=Team.objects.all())

And I’d also suggest looking at Select2 which creates a javascript ‘search’ type field that will filter the teams when someone starts to type characters.

Furthermore, the user field in your Team model would be better named as creator or owner so that you don’t confuse them with a standard user associated with the team.

Leave a comment