How do I test Django QuerySets are equal?

前端 未结 6 755
挽巷
挽巷 2020-12-17 07:40

I am trying to test my Django views. This view passes a QuerySet to the template:

def merchant_home(request, slug):
  merchant = Merchant.objects.get(slug=sl         


        
6条回答
  •  再見小時候
    2020-12-17 08:32

    I ended up solving this issue using map to repr() each entry in the queryset inside the self.assertQuerysetEqual call, e.g.

    self.assertQuerysetEqual(queryset_1, map(repr, queryset_2))
    

提交回复
热议问题