Similar DynamicRelationFields with different querysets are not respected
Closed this issue · 5 comments
I'm trying to do something along these lines to provide a prefiltered view of a related table however I'm finding that the cache is being a bit aggressive and ignoring the different querysets that I've asked for, instead only using the queryset from the first field to be defined.
As an aside if I go to the deferred link this would generate. E.g. /company/<id>/recent_quotes/
then it actually works as I'd expect.
class CompanySerializer(DynamicModelSerializer):
recent_purchases = DynamicRelationField(
'CRM.serializer.TransactionSerializer',
source='transaction_set',
many=True,
queryset=Transaction.objects.filter(state=Transaction.STATE.PURCHASED),
deferred=True
)
recent_quotes = DynamicRelationField(
'CRM.serializer.TransactionSerializer',
source='transaction_set',
many=True,
queryset=Transaction.objects.filter(state=Transaction.STATE.QUOTE),
deferred=True
)
I believe we recently fixed a similar issue. Which version of DREST are you using?
1.9.5, you've not released 1.9.6 on pypi yet
Thanks. Just released 1.9.6, which has a fix for a similar issue (though might also be different) so let us know if that works!
I've been off sick so we're going to test this sometime this week instead