Corrected caching extra (cache the values, not the queryset object)

This commit is contained in:
Saria Hajjar 2020-02-21 14:20:46 +00:00
parent be307b4574
commit 6fa80bd971

View File

@ -399,7 +399,7 @@ class PowerPort(CableTermination, ComponentModel):
outlets = PowerOutlet.objects.filter(power_port=self) outlets = PowerOutlet.objects.filter(power_port=self)
# The outlets are used as extra to invalidate the cache when an outlet's leg is changed # The outlets are used as extra to invalidate the cache when an outlet's leg is changed
@cached_as(self, extra=outlets) @cached_as(self, extra=list(outlets.values_list('pk', flat=True)))
def _stats(): def _stats():
# Power ports drawing power from the local outlets # Power ports drawing power from the local outlets
return PowerPort.objects.filter( return PowerPort.objects.filter(