From d15a4da84061798ca824dd271dad704459e8d159 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Tue, 17 Apr 2018 18:03:10 +0200 Subject: [PATCH] Check if child plugin instances exist before looping over them --- datacenterlight/cms_plugins.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/datacenterlight/cms_plugins.py b/datacenterlight/cms_plugins.py index 2ad07249..6533adc7 100644 --- a/datacenterlight/cms_plugins.py +++ b/datacenterlight/cms_plugins.py @@ -92,13 +92,14 @@ class DCLCalculatorPlugin(CMSPluginBase): context['children_to_side'] = [] context['children_to_content'] = [] pricing_plugin_model = None - for child in instance.child_plugin_instances: - if child.__class__.__name__ == 'DCLCustomPricingModel': - # The second clause is just to make sure we pick up the most - # recent CustomPricing, if more than one is present - if (pricing_plugin_model is None or child.pricing_id > - pricing_plugin_model.model.pricing_id): - pricing_plugin_model = child + if instance.child_plugin_instances: + for child in instance.child_plugin_instances: + if child.__class__.__name__ == 'DCLCustomPricingModel': + # The second clause is just to make sure we pick up the + # most recent CustomPricing, if more than one is present + if (pricing_plugin_model is None or child.pricing_id > + pricing_plugin_model.model.pricing_id): + pricing_plugin_model = child if pricing_plugin_model: context['vm_pricing'] = VMPricing.get_vm_pricing_by_name(