By default assertQuerysetEqual
uses repr()
on the first argument. This is why you were having issues with the strings in the queryset comparison.
To work around this you can override the transform
argument with a lambda
function that doesn’t use repr()
:
self.assertQuerysetEqual(queryset_1, queryset_2, transform=lambda x: x)