Simplify function code while maintaining readability

Advertisements This code works, but seems too redundant to me. Is it possible to somehow simplify it while maintaining functionality and readability? has_videos = self.request.query_params.get(‘has_videos’) if has_videos: if has_videos == ‘true’: entries = User.objects.filter(videos__isnull=False) elif has_videos == ‘false’: entries = User.objects.filter(videos__isnull=True) else: entries = User.objects.all() I tried to write in one line using the ternary… Read More Simplify function code while maintaining readability