Merge two ORM QuerySet based on condition

Viewed 11

I have two QuerySet:

<QuerySet [{'user': 16, 'count': 0}, {'user': 17, 'count': 0}, {'user': 18, 'count': 0}]>

<QuerySet [{'user': 17, 'count': 6}]>

Now I want to merge the above two QuerySet, so if any user has a count in QuerySet2, it will overlap its value in QuerySet1.

The result should be like this:

<QuerySet [{'user': 16, 'count': 0}, {'user': 17, 'count': 6}, {'user': 18, 'count': 0}]>

I have tried join, but it didn't work for me.

0 Answers
Related