Получение TypeError: 'NoneType' при присвоении переменной значения поля django json

вот код

    def energy_capacity_before_losses_for_tranche_gt_one_for_year(self, year, tranche, tranche_year_value):
       
        print('tranche', tranche)
        tranche_stack_quantity = self.tranches_stack_quantity[1]   ----> Error here
        if tranche_year_value in ["-", ""] or tranche_stack_quantity in ["-", ""]:
            return D(0.0)

        if int(tranche_year_value) <= year:
            if tranche_stack_quantity and self.contracted_stack_capacity_tranche:
                result = (
                    D(DEGRADATION_WITH_PG_MATRIX_TRANCHE_GREATER_THAN_ONE / 100) *
                    int(tranche_stack_quantity) *
                    D(self.contracted_stack_capacity_tranche / 1000)
                )
                return result

        return D(0.0)
    
    def energy_capacity_before_losses_for_tranche_gt_one(self, tranche, tranche_year_value):
        return {
            year: self.energy_capacity_before_losses_for_tranche_gt_one_for_year(year, tranche, tranche_year_value)
            for year in self.years
        }
    
    def energy_capacity_before_losses_for_tranches(self):
        result = {
            1: self.energy_capacity_before_losses_for_tranche_one()
        }
        for tranche, tranche_value in enumerate(self.augmentation_before_start_of_year[1:], start=2):
            result[tranche] = self.energy_capacity_before_losses_for_tranche_gt_one(
                tranche=tranche, tranche_year_value=tranche_value
            )
        return result

у меня возникает ошибка в этой строке

line 63, in energy_capacity_before_losses_for_tranche_gt_one_for_year
tranche_stack_quantity = self.tranches_stack_quantity[1]
TypeError: 'NoneType' object is not subscriptable

и , значения self.tranches_stack_quantity являются

["", "2", "", "", "", "", "", "", "", "", ""] и это поле django json

я пытаюсь присвоить tranche_stack_quantity = self.tranches_stack_quantity[1] для меня это выглядит нормально, но я не знаю, почему это происходит

Примечание: остальные значения получены из констант или расчетов по формулам

и energy_capacity_before_losses_for_tranches() - родительские функции, а остальные - последовательно зависимые функции

Вернуться на верх