You won't believe this!
A colleague of mine met me yesterday just before we closed for the day, and he said to me:
"Boss, you said you're going to assign the marketing lead to us. Are we still getting that today?"
I responded, "yes, you are".
Practically, it's not possible that evening (because we're talking about over 500 submitted contacts here...).
While it isn't possible to manually achieve all of the tasks the same evening (of course, I was too tired to go through the 500 contact list), programmatically, it is possible.
I just told my colleague to check back in a few minutes.
Just for a few minutes, I came up with logic that could do the updates for me in seconds.
Although I wrote the logic for just a shortlist of 500 entries (which might look small), these same 16 lines of code can perform the same task on millions of entries in seconds without me moving an inch.
Ask the computer to do it for you whenever you feel something is too redundant.
from marketing.models import KidsCanCode # Import your data table from django.contrib.auth.models import User # Import the staff # Grab the KidsCanCode table and assign to staff def update_marketing_field():
p = KidsCanCode.objects.filter(timestamp__year='2021', timestamp__month='11')
timothy = User.objects.get(username='BlueTimothyOsadebeb')
ods = User.objects.get(username='ODS')
count = 0
for pa in p:
if (count % 2) == 0: # Check if there is no remainder
pa.staff = timothy
pa.staff = ods
count += 1