diff --git a/equipment_tracker/transactions/serializers.py b/equipment_tracker/transactions/serializers.py index 4eb567f..7d6256f 100644 --- a/equipment_tracker/transactions/serializers.py +++ b/equipment_tracker/transactions/serializers.py @@ -191,6 +191,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): # This updates the status field of all equipment instances in a single query EquipmentInstance.objects.filter( id__in=[equipment.id for equipment in equipments]).update(status='Available') + cache.delete('available_equipment_instances') + cache.delete('equipment_instances') return super().update(instance, validated_data) # For Approved transactions, @@ -208,6 +210,8 @@ class TransactionSerializer(serializers.HyperlinkedModelSerializer): # This updates the status field of all equipment instances in a single query EquipmentInstance.objects.filter( id__in=[equipment.id for equipment in equipments]).update(status='Available') + cache.delete('available_equipment_instances') + cache.delete('equipment_instances') return super().update(instance, validated_data) # If there are no issues and a transaction changes from Approved to Borrowed, label the selected equipment's statuses as Borrowed