evolution-chain bug fix

This commit is contained in:
Adickes 2015-11-16 15:42:24 -05:00
parent 342ea98b87
commit 300f1a9b79

View file

@ -2662,14 +2662,17 @@ class EvolutionChainDetailSerializer(serializers.ModelSerializer):
entry = OrderedDict()
evolution_object = PokemonEvolution.objects.get(evolved_species=species['id'])
evolution_data = PokemonEvolutionSerializer(evolution_object, context=self.context).data
many=False
try:
evolution_object = PokemonEvolution.objects.get(evolved_species=species['id'])
except PokemonEvolution.MultipleObjectsReturned:
evolution_object = PokemonEvolution.objects.filter(evolved_species=species['id'])
many=True
print evolution_data
evolution_data = PokemonEvolutionSerializer(evolution_object, many=many, context=self.context).data
current_evolutions.append(entry)
entry['is_baby'] = species['is_baby']
entry['species'] = summary_data[index]
if evolution_data: entry['evolution_details'] = evolution_data