Skip to content

feat: fallback front_female sprite to front_default for female-only p…#1573

Open
programgames wants to merge 2 commits into
PokeAPI:masterfrom
programgames:271-female-sprites
Open

feat: fallback front_female sprite to front_default for female-only p…#1573
programgames wants to merge 2 commits into
PokeAPI:masterfrom
programgames:271-female-sprites

Conversation

@programgames

@programgames programgames commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Changes description

A simple solution for the #271 .
If the request if a simple GET for the pokemon, we select the specie and check if the gender rate is only female.
In this case we copy the valuer from default to female sprites with this mapping :

_FEMALE_FALLBACKS = {
    "front_female": "front_default",
    "back_female": "back_default",
    "front_shiny_female": "front_shiny",
    "back_shiny_female": "back_shiny",
}

PS : I would like to know if Pokemon.objects.all().select_related("pokemon_species") could be a performance problem on the server, Should I test performance before and after this change to compare ?

sprite keys with their default counterparts across all sprite sections.
Comment thread pokemon_v2/api.py
serializer_class = PokemonDetailSerializer
list_serializer_class = PokemonSummarySerializer

def get_queryset(self):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very interesting implementation. Can I ask what's the purpose of this function? It's for having ready at hand some data later on in the serializer.py part?

Comment thread pokemon_v2/serializers.py
"back_shiny_female": "back_shiny",
}

def _fill_female_sprites(self, node):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm strongly of the opinion that the data should just be shared with PokeAPI and consumers should handle this themselves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants