Might be shorter/clearer to do
```python
return any(user.groups.filter(name=groupname).exists() for groupname in groupnames)
```
Note the lack of brackets around the list comprehension -- that makes it a generator expression, so that it's lazily evaluated. It will only do database queries until one of the items exist, and then the rest of the generator will be discarded.