nlassaux
nlassaux

Reputation: 2406

'Need more than 1 value to unpack' error with a filter

I have an error on a filter : need more than 1 value to unpack

Is it correct :

groups_list = Group.objects.filter({'assignment__in': editedcourse.assignment.all()})

I think it is a syntax error, or given arguments lack off but I can't correct it :/

Upvotes: 0

Views: 1203

Answers (1)

levi
levi

Reputation: 22697

try without { } and ''

groups_list = Group.objects.filter(assignment__in= editedcourse.assignment.all())

or

ids = map(lambda x:x.id,editedcourse.assignment.all())
groups_list = Group.objects.filter(assignment__in=ids)

Upvotes: 1

Related Questions