I wrote the method to check one attribute and return False if there is an artist with selling=False, and True otherwise.
def check_selling(track, excludes):
"""
Returns True if all track's artists are allowed for selling. False otherwise
"""
for artist in track.artists.all():
if not artist.selling:
excludes.append(track.pk)
return False
return True
How can i minimize this?
I tried:
def check_selling(track, excludes):
res = excludes.append(track.pk) if not [artist.selling for artist in track.artists.all()] else True
return res or False
But [False] or [True] resulting in list comprehension [artist.selling for artist in track.artists.all()] always gives True...