'Using F function into annotate
i have a problem about using f function into annotating i use F function to retreive "user__id" and pass it to get_user_daynum that it should returns a number but it always returns a same number. after that i filter them by creating a lookup_field. i test the get_user_daynum many times and i get correct number but about using it in annotate i'm confused.
for date, days in valid_date_days.items():
lookup_field = f'{date}__in'
intended_user_workpattern = intended_user_workpattern.annotate(
**{date: Value(get_user_daynum(date, F('user__id'), request_user_wp.work_pattern))}
)
intended_user_workpattern = intended_user_workpattern.filter(
**{lookup_field: list(days)}
)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
