I have 2 querysets from 2 different models like this:
qs1=[[username1, lastname1, firstname1], [username2, lastname2, firstname2]........[username10, lastname10, firstname10]]
qs2=[[username1, email1], [username2, email2]...[username10, email10]]
I need to combine them to one and sorted by username. So it becomes like this:
qs=[[username1, lastname1, firstname1, email1], [username2, lastname2, firstname2, email2]...[username10, lastname10, firstname10, email10]]
qs1 and qs2 are querysets with multiple entries.
I have code in view.py like this:
usernames = C.objects.values('username')
for username in usernames:
try:
qs1=A.objects.filter(username=username).values('username','lastname',' 'firstname')
qs2=B.objects.filter(username=username).values('username','email')
qs = sorted(chain(qs1, qs2))
return qs
How do I combine qs1 and qs2 to qs?