Reputation: 9956
I am attempting to clear all the users from a table called Team
based on two factors:
team_id
level
Bellow is my current effort, I am well aware this is does not work but at least it's a starting point.
team = Team.objects.get(pk = team_id)
team_user_list = team.users.all().filter(userprofile__level = 1)
team_user_list.users.clear()
Note: I don't want to delete the users, simply remove them from the team table.
Upvotes: 0
Views: 181
Reputation: 8241
team_user_list
is queryset, so it doesn't have users
attribute. Try
team = Team.objects.get(pk = team_id)
filtered = team.users.filter(userprofile__level = 1)
team.users.remove(*filtered)
Upvotes: 1