1👍
✅
The easiest way to solve this is to use a keyword parameter in your lambda:
user = User.objects.get(username="jamie")
sorted(Task.objects.all(), key = lambda task, user=user: task.date_for_display(user))
This copies the user from the outer scope into the local scope of your lambda.
- [Answer]-How could I allow copy editors for my Django site to create internal links in a DRY manner?
Source:stackexchange.com