Closed lampslave closed 7 years ago
Hmmm... I'm on the fence. Our habit is to break it up into multiple variable assignments, but I see that your convention is valid too. Perhaps we should mention both approaches?
Perhaps we should mention both approaches?
Would be great :)
I use this convention because I prefer long names (this code is synthetic but not impossible):
current_user_agency_tasks = AgencyTask.objects \
.filter(agency__employee_profiles__user=current_user) \
.exclude(status__in=[AgencyTask.STATUS_DONE,
AgencyTask.STATUS_EXPIRED]) \
.prefetch_related('project__employee_profiles__groups')
vs
currenct_user_agency_tasks = AgencyTask.objects.filter(
agency__employee_profiles__user=current_user)
currenct_user_agency_tasks = currenct_user_agency_tasks.exclude(
status__in=[AgencyTask.STATUS_DONE, AgencyTask.STATUS_EXPIRED])
currenct_user_agency_tasks = currenct_user_agency_tasks.prefetch_related(
'project__employee_profiles__groups')
vs
current_user_agency_tasks = AgencyTask.objects.filter(
agency__employee_profiles__user=current_user
).exclude(
status__in=[AgencyTask.STATUS_DONE,
AgencyTask.STATUS_EXPIRED]
).prefetch_related(
'project__employee_profiles__groups'
)
vs
currenct_user_agency_tasks = AgencyTask.objects.filter(agency__employee_profiles__user=current_user)
currenct_user_agency_tasks = currenct_user_agency_tasks.exclude(status__in=[AgencyTask.STATUS_DONE, AgencyTask.STATUS_EXPIRED])
currenct_user_agency_tasks = currenct_user_agency_tasks.prefetch_related('project__employee_profiles__groups')
Nicely stated! Could you add your real name to your GitHub profile so we can provide proper accreditation for your suggestion?
Yes, sure. Thanks a lot.
Finally added as a legibility alternative! Yeah!
🚢 :shipit: 🍨
I think this code is much clearer than current version: