Started on pokemon. theyre a bit more complex than v1. not sure hot to break them up.

This commit is contained in:
Adickes 2015-09-19 18:13:41 -04:00
parent 3b8b1a6cf0
commit 16c4ae33ea
7 changed files with 483 additions and 105 deletions

View file

@ -89,7 +89,7 @@ DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'pokeapi_co_db',
'USER': 'zane',
'USER': 'root',
'PASSWORD': 'pokeapi',
'HOST': 'localhost',
'PORT': '',

View file

@ -49,11 +49,14 @@ router = routers.DefaultRouter()
router.register(r"ability", AbilityResource)
router.register(r"generation", GenerationResource)
router.register(r"growthrate", GrowthRateResource)
router.register(r"language", LanguageResource)
router.register(r"move", MoveResource)
router.register(r"nature", NatureResource)
router.register(r"pokedex", PokedexResource)
router.register(r"pokemon", PokemonResource)
router.register(r"pokemon-shape", PokemonShapeResource)
router.register(r"pokemon-color", PokemonColorResource)
router.register(r"region", RegionResource)
router.register(r"type", TypeResource)
router.register(r"version", VersionResource)

View file

@ -6,7 +6,7 @@ from django.db import models, migrations
class Migration(migrations.Migration):
replaces = [(b'pokemon_v2', '0001_squashed_0013_auto_20150420_0114'), (b'pokemon_v2', '0002_auto_20150910_0153'), (b'pokemon_v2', '0003_auto_20150910_0223'), (b'pokemon_v2', '0004_auto_20150910_0225'), (b'pokemon_v2', '0005_auto_20150910_0353'), (b'pokemon_v2', '0006_auto_20150910_0357')]
replaces = [(b'pokemon_v2', '0001_squashed_0006_auto_20150910_0357'), (b'pokemon_v2', '0002_auto_20150914_1324'), (b'pokemon_v2', '0003_auto_20150915_0055'), (b'pokemon_v2', '0004_auto_20150915_0448'), (b'pokemon_v2', '0005_auto_20150918_0502')]
dependencies = [
]
@ -32,7 +32,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('local_language_id', models.IntegerField()),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='languagenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='languagename_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -107,7 +107,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('ability', models.ForeignKey(related_name='abilityname', blank=True, to='pokemon_v2.Ability', null=True)),
('language', models.ForeignKey(related_name='abilitynamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='abilityname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -143,7 +143,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('pokemon_move_method_id', models.IntegerField()),
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
('version_group', models.ForeignKey(related_name='versiongrouppokemonmovemethod', blank=True, to='pokemon_v2.VersionGroup', null=True)),
],
options={
'abstract': False,
@ -166,7 +166,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='versionnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='versionname_language', blank=True, to='pokemon_v2.Language', null=True)),
('version', models.ForeignKey(blank=True, to='pokemon_v2.Version', null=True)),
],
options={
@ -183,13 +183,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='abilityflavortext',
name='version_group',
field=models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True),
field=models.ForeignKey(related_name='abilityflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='generationname',
name='language',
field=models.ForeignKey(related_name='generationnamelanguage', blank=True, to='pokemon_v2.Language', null=True),
field=models.ForeignKey(related_name='generationname_language', blank=True, to='pokemon_v2.Language', null=True),
preserve_default=True,
),
migrations.AlterField(
@ -222,8 +222,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('game_index', models.IntegerField()),
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
('type', models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True)),
('generation', models.ForeignKey(related_name='typegameindex', blank=True, to='pokemon_v2.Generation', null=True)),
('type', models.ForeignKey(related_name='typegameindex', blank=True, to='pokemon_v2.Type', null=True)),
],
options={
'abstract': False,
@ -235,8 +235,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='typenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('type', models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True)),
('language', models.ForeignKey(related_name='typename_language', blank=True, to='pokemon_v2.Language', null=True)),
('type', models.ForeignKey(related_name='typename', blank=True, to='pokemon_v2.Type', null=True)),
],
options={
'abstract': False,
@ -247,8 +247,6 @@ class Migration(migrations.Migration):
name='TypeEfficacy',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('damage_type_id', models.IntegerField()),
('target_type_id', models.IntegerField()),
('damage_factor', models.IntegerField()),
],
options={
@ -302,7 +300,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='statnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='statname_language', blank=True, to='pokemon_v2.Language', null=True)),
('stat', models.ForeignKey(blank=True, to='pokemon_v2.Stat', null=True)),
],
options={
@ -331,7 +329,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='naturenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='naturename_language', blank=True, to='pokemon_v2.Language', null=True)),
('nature', models.ForeignKey(blank=True, to='pokemon_v2.Nature', null=True)),
],
options={
@ -369,7 +367,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('characteristic', models.ForeignKey(blank=True, to='pokemon_v2.Characteristic', null=True)),
('language', models.ForeignKey(related_name='characteristicdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='characteristicdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -393,7 +391,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('egg_group', models.ForeignKey(blank=True, to='pokemon_v2.EggGroup', null=True)),
('language', models.ForeignKey(related_name='egggroupnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='egggroupname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -417,7 +415,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('growth_rate', models.ForeignKey(blank=True, to='pokemon_v2.GrowthRate', null=True)),
('language', models.ForeignKey(related_name='growthratedescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='growthratedescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('description', models.CharField(default='', max_length=1000)),
],
options={
@ -461,7 +459,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='movebattlestylenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movebattlestylename_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_battle_style', models.ForeignKey(blank=True, to='pokemon_v2.MoveBattleStyle', null=True)),
],
options={
@ -501,7 +499,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='movedamageclassdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movedamageclassdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_damage_class', models.ForeignKey(blank=True, to='pokemon_v2.MoveDamageClass', null=True)),
],
options={
@ -535,7 +533,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('effect', models.CharField(max_length=4000)),
('language', models.ForeignKey(related_name='moveeffectchangedescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='moveeffectchangedescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_effect_change', models.ForeignKey(blank=True, to='pokemon_v2.MoveEffectChange', null=True)),
],
options={
@ -549,7 +547,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('short_effect', models.CharField(max_length=300)),
('effect', models.CharField(max_length=4000)),
('language', models.ForeignKey(related_name='moveeffectdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='moveeffectdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_effect', models.ForeignKey(blank=True, to='pokemon_v2.MoveEffect', null=True)),
],
options={
@ -574,7 +572,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='moveflagdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='moveflagdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_flag', models.ForeignKey(blank=True, to='pokemon_v2.MoveFlag', null=True)),
],
options={
@ -599,9 +597,9 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('flavor_text', models.CharField(max_length=500)),
('language', models.ForeignKey(related_name='moveflavortextlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='moveflavortext_language', blank=True, to='pokemon_v2.Language', null=True)),
('move', models.ForeignKey(blank=True, to='pokemon_v2.Move', null=True)),
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
('version_group', models.ForeignKey(related_name='moveflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True)),
],
options={
'abstract': False,
@ -644,7 +642,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='movemetaailmentnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movemetaailmentname_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_meta_ailment', models.ForeignKey(blank=True, to='pokemon_v2.MoveMetaAilment', null=True)),
],
options={
@ -668,7 +666,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('language', models.ForeignKey(related_name='movemetacategorydescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movemetacategorydescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_meta_category', models.ForeignKey(blank=True, to='pokemon_v2.MoveMetaCategory', null=True)),
],
options={
@ -694,7 +692,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='movenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movename_language', blank=True, to='pokemon_v2.Language', null=True)),
('move', models.ForeignKey(blank=True, to='pokemon_v2.Move', null=True)),
],
options={
@ -719,7 +717,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='movetargetdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='movetargetdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('move_target', models.ForeignKey(blank=True, to='pokemon_v2.MoveTarget', null=True)),
],
options={
@ -754,13 +752,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='movechange',
name='type',
field=models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True),
field=models.ForeignKey(related_name='movechange', blank=True, to='pokemon_v2.Type', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='movechange',
name='version_group',
field=models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True),
field=models.ForeignKey(related_name='movechange', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AddField(
@ -1230,7 +1228,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('effect', models.CharField(max_length=4000)),
('ability_change', models.ForeignKey(blank=True, to='pokemon_v2.AbilityChange', null=True)),
('language', models.ForeignKey(related_name='abilitychangedescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='abilitychangedescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -1264,7 +1262,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('evolution_trigger', models.ForeignKey(blank=True, to='pokemon_v2.EvolutionTrigger', null=True)),
('language', models.ForeignKey(related_name='evolutiontriggernamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='evolutiontriggername_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -1314,8 +1312,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='pokedexdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('pokedex', models.ForeignKey(blank=True, to='pokemon_v2.Pokedex', null=True)),
('language', models.ForeignKey(related_name='pokedexdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokedex', models.ForeignKey(related_name='pokedexdescription', blank=True, to='pokemon_v2.Pokedex', null=True)),
],
options={
'abstract': False,
@ -1326,8 +1324,8 @@ class Migration(migrations.Migration):
name='PokedexVersionGroup',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('pokedex', models.ForeignKey(blank=True, to='pokemon_v2.Pokedex', null=True)),
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
('pokedex', models.ForeignKey(related_name='pokedexversiongroup', blank=True, to='pokemon_v2.Pokedex', null=True)),
('version_group', models.ForeignKey(related_name='pokedexversiongroup', blank=True, to='pokemon_v2.VersionGroup', null=True)),
],
options={
'abstract': False,
@ -1380,7 +1378,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='pokemoncolornamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='pokemoncolorname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_color', models.ForeignKey(blank=True, to='pokemon_v2.PokemonColor', null=True)),
],
options={
@ -1456,7 +1454,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('game_index', models.IntegerField()),
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
('generation', models.ForeignKey(related_name='pokemonformgeneration', blank=True, to='pokemon_v2.Generation', null=True)),
('pokemon_form', models.ForeignKey(blank=True, to='pokemon_v2.PokemonForm', null=True)),
],
options={
@ -1470,7 +1468,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('pokemon_name', models.CharField(max_length=30)),
('language', models.ForeignKey(related_name='pokemonformnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='pokemonformname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_form', models.ForeignKey(blank=True, to='pokemon_v2.PokemonForm', null=True)),
],
options={
@ -1484,7 +1482,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('game_index', models.IntegerField()),
('pokemon', models.ForeignKey(blank=True, to='pokemon_v2.Pokemon', null=True)),
('version', models.ForeignKey(blank=True, to='pokemon_v2.Version', null=True)),
('version', models.ForeignKey(related_name='pokemongameindex', blank=True, to='pokemon_v2.Version', null=True)),
],
options={
'abstract': False,
@ -1507,7 +1505,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='pokemonhabitatnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='pokemonhabitatname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_habitat', models.ForeignKey(blank=True, to='pokemon_v2.PokemonHabitat', null=True)),
],
options={
@ -1559,7 +1557,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='pokemonmovemethodnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='pokemonmovemethodname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_move_method', models.ForeignKey(blank=True, to='pokemon_v2.PokemonMoveMethod', null=True)),
],
options={
@ -1584,8 +1582,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('awesome_name', models.CharField(max_length=30)),
('language', models.ForeignKey(related_name='pokemonshapenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_shape', models.ForeignKey(blank=True, to='pokemon_v2.PokemonShape', null=True)),
('language', models.ForeignKey(related_name='pokemonshapename_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_shape', models.ForeignKey(related_name='pokemonshapename', blank=True, to='pokemon_v2.PokemonShape', null=True)),
],
options={
'abstract': False,
@ -1623,8 +1621,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('description', models.CharField(default='', max_length=1000)),
('language', models.ForeignKey(related_name='pokemonspeciesdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
('language', models.ForeignKey(related_name='pokemonspeciesdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(related_name='pokemonspeciesdescription', blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
],
options={
'abstract': False,
@ -1636,9 +1634,9 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('flavor_text', models.CharField(max_length=500)),
('language', models.ForeignKey(related_name='pokemonspeciesflavortextlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
('version', models.ForeignKey(blank=True, to='pokemon_v2.Version', null=True)),
('language', models.ForeignKey(related_name='pokemonspeciesflavortext_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(related_name='pokemonspeciesflavortext', blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
('version', models.ForeignKey(related_name='pokemonspeciesflavortext', blank=True, to='pokemon_v2.Version', null=True)),
],
options={
'abstract': False,
@ -1651,8 +1649,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('genus', models.CharField(max_length=30)),
('language', models.ForeignKey(related_name='pokemonspeciesnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
('language', models.ForeignKey(related_name='pokemonspeciesname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokemon_species', models.ForeignKey(related_name='pokemonspeciesname', blank=True, to='pokemon_v2.PokemonSpecies', null=True)),
],
options={
'abstract': False,
@ -1679,7 +1677,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('slot', models.IntegerField()),
('pokemon', models.ForeignKey(blank=True, to='pokemon_v2.Pokemon', null=True)),
('type', models.ForeignKey(blank=True, to='pokemon_v2.Type', null=True)),
('type', models.ForeignKey(related_name='pokemontype', blank=True, to='pokemon_v2.Type', null=True)),
],
options={
'abstract': False,
@ -1695,7 +1693,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='pokemonmove',
name='version_group',
field=models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True),
field=models.ForeignKey(related_name='pokemonmove', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AddField(
@ -1743,13 +1741,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='pokemonegggroup',
name='pokemon_species',
field=models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True),
field=models.ForeignKey(related_name='pokemonegggroup', blank=True, to='pokemon_v2.PokemonSpecies', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='pokemondexnumber',
name='pokemon_species',
field=models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True),
field=models.ForeignKey(related_name='pokemondexnumber', blank=True, to='pokemon_v2.PokemonSpecies', null=True),
preserve_default=True,
),
migrations.AddField(
@ -1947,7 +1945,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('item_category', models.ForeignKey(blank=True, to='pokemon_v2.ItemCategory', null=True)),
('language', models.ForeignKey(related_name='itemcategorynamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itemcategoryname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -1961,7 +1959,7 @@ class Migration(migrations.Migration):
('effect', models.CharField(max_length=4000)),
('short_effect', models.CharField(max_length=300)),
('item', models.ForeignKey(blank=True, to='pokemon_v2.Item', null=True)),
('language', models.ForeignKey(related_name='itemdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itemdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -1986,7 +1984,7 @@ class Migration(migrations.Migration):
('description', models.CharField(default='', max_length=1000)),
('name', models.CharField(max_length=100)),
('item_flag', models.ForeignKey(blank=True, to='pokemon_v2.ItemFlag', null=True)),
('language', models.ForeignKey(related_name='itemflagdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itemflagdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2011,8 +2009,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('flavor_text', models.CharField(max_length=500)),
('item', models.ForeignKey(blank=True, to='pokemon_v2.Item', null=True)),
('language', models.ForeignKey(related_name='itemflavortextlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
('language', models.ForeignKey(related_name='itemflavortext_language', blank=True, to='pokemon_v2.Language', null=True)),
('version_group', models.ForeignKey(related_name='itemflavortext', blank=True, to='pokemon_v2.VersionGroup', null=True)),
],
options={
'abstract': False,
@ -2034,7 +2032,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('effect', models.CharField(max_length=4000)),
('item_fling_effect', models.ForeignKey(blank=True, to='pokemon_v2.ItemFlingEffect', null=True)),
('language', models.ForeignKey(related_name='itemflingeffectdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itemflingeffectdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2046,7 +2044,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('game_index', models.IntegerField()),
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
('generation', models.ForeignKey(related_name='itemgameindex', blank=True, to='pokemon_v2.Generation', null=True)),
('item', models.ForeignKey(blank=True, to='pokemon_v2.Item', null=True)),
],
options={
@ -2060,7 +2058,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('item', models.ForeignKey(blank=True, to='pokemon_v2.Item', null=True)),
('language', models.ForeignKey(related_name='itemnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itemname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2084,7 +2082,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('item_pocket', models.ForeignKey(blank=True, to='pokemon_v2.ItemPocket', null=True)),
('language', models.ForeignKey(related_name='itempocketnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='itempocketname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2172,7 +2170,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('berry_firmness', models.ForeignKey(blank=True, to='pokemon_v2.BerryFirmness', null=True)),
('language', models.ForeignKey(related_name='berryfirmnessnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='berryfirmnessname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2220,7 +2218,7 @@ class Migration(migrations.Migration):
('effect', models.CharField(max_length=4000)),
('flavor_text', models.CharField(max_length=500)),
('contest_effect', models.ForeignKey(blank=True, to='pokemon_v2.ContestEffect', null=True)),
('language', models.ForeignKey(related_name='contesteffectdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='contesteffectdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2246,7 +2244,7 @@ class Migration(migrations.Migration):
('flavor', models.CharField(max_length=10)),
('color', models.CharField(max_length=10)),
('contest_type', models.ForeignKey(blank=True, to='pokemon_v2.ContestType', null=True)),
('language', models.ForeignKey(related_name='contesttypenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='contesttypename_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2292,7 +2290,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='abilitydescription',
name='language',
field=models.ForeignKey(related_name='abilitydescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True),
field=models.ForeignKey(related_name='abilitydescription_language', blank=True, to='pokemon_v2.Language', null=True),
preserve_default=True,
),
migrations.CreateModel(
@ -2311,8 +2309,8 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='regionnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('region', models.ForeignKey(blank=True, to='pokemon_v2.Region', null=True)),
('language', models.ForeignKey(related_name='regionname_language', blank=True, to='pokemon_v2.Language', null=True)),
('region', models.ForeignKey(related_name='regionname', blank=True, to='pokemon_v2.Region', null=True)),
],
options={
'abstract': False,
@ -2336,13 +2334,13 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='pokedex',
name='region',
field=models.ForeignKey(blank=True, to='pokemon_v2.Region', null=True),
field=models.ForeignKey(related_name='pokedex', blank=True, to='pokemon_v2.Region', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='versiongroupregion',
name='region',
field=models.ForeignKey(blank=True, to='pokemon_v2.Region', null=True),
field=models.ForeignKey(related_name='versiongroupregion', blank=True, to='pokemon_v2.Region', null=True),
preserve_default=True,
),
migrations.CreateModel(
@ -2388,7 +2386,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='locationareanamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='locationareaname_language', blank=True, to='pokemon_v2.Language', null=True)),
('location_area', models.ForeignKey(blank=True, to='pokemon_v2.LocationArea', null=True)),
],
options={
@ -2401,7 +2399,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('game_index', models.IntegerField()),
('generation', models.ForeignKey(blank=True, to='pokemon_v2.Generation', null=True)),
('generation', models.ForeignKey(related_name='locationgameindex', blank=True, to='pokemon_v2.Generation', null=True)),
('location', models.ForeignKey(blank=True, to='pokemon_v2.Location', null=True)),
],
options={
@ -2414,7 +2412,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='locationnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='locationname_language', blank=True, to='pokemon_v2.Language', null=True)),
('location', models.ForeignKey(blank=True, to='pokemon_v2.Location', null=True)),
],
options={
@ -2454,7 +2452,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('encounter_condition', models.ForeignKey(blank=True, to='pokemon_v2.EncounterCondition', null=True)),
('language', models.ForeignKey(related_name='encounterconditionnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='encounterconditionname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2491,7 +2489,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('encounter_condition_value', models.ForeignKey(blank=True, to='pokemon_v2.EncounterConditionValue', null=True)),
('language', models.ForeignKey(related_name='encounterconditionvaluenamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='encounterconditionvaluename_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2516,7 +2514,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('encounter_method', models.ForeignKey(blank=True, to='pokemon_v2.EncounterMethod', null=True)),
('language', models.ForeignKey(related_name='encountermethodnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='encountermethodname_language', blank=True, to='pokemon_v2.Language', null=True)),
],
options={
'abstract': False,
@ -2530,7 +2528,7 @@ class Migration(migrations.Migration):
('slot', models.IntegerField(null=True, blank=True)),
('rarity', models.IntegerField()),
('encounter_method', models.ForeignKey(blank=True, to='pokemon_v2.EncounterMethod', null=True)),
('version_group', models.ForeignKey(blank=True, to='pokemon_v2.VersionGroup', null=True)),
('version_group', models.ForeignKey(related_name='encounterslot', blank=True, to='pokemon_v2.VersionGroup', null=True)),
],
options={
'abstract': False,
@ -2577,7 +2575,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='palparkareanamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='palparkareaname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pal_park_area', models.ForeignKey(blank=True, to='pokemon_v2.PalParkArea', null=True)),
],
options={
@ -2601,7 +2599,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('name', models.CharField(max_length=100)),
('language', models.ForeignKey(related_name='pokeathlonstatnamelanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='pokeathlonstatname_language', blank=True, to='pokemon_v2.Language', null=True)),
('pokeathlon_stat', models.ForeignKey(blank=True, to='pokemon_v2.PokeathlonStat', null=True)),
],
options={
@ -2635,7 +2633,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('flavor_text', models.CharField(max_length=500)),
('language', models.ForeignKey(related_name='supercontesteffectdescriptionlanguage', blank=True, to='pokemon_v2.Language', null=True)),
('language', models.ForeignKey(related_name='supercontesteffectdescription_language', blank=True, to='pokemon_v2.Language', null=True)),
('super_contest_effect', models.ForeignKey(blank=True, to='pokemon_v2.SuperContestEffect', null=True)),
],
options={
@ -2652,7 +2650,7 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='palpark',
name='pokemon_species',
field=models.ForeignKey(blank=True, to='pokemon_v2.PokemonSpecies', null=True),
field=models.ForeignKey(related_name='palpark', blank=True, to='pokemon_v2.PokemonSpecies', null=True),
preserve_default=True,
),
migrations.AddField(
@ -2721,4 +2719,124 @@ class Migration(migrations.Migration):
field=models.ForeignKey(related_name='abilityflavortextlanguage', blank=True, to='pokemon_v2.Language', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='ability',
name='generation',
field=models.ForeignKey(related_name='ability', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='abilityflavortext',
name='language',
field=models.ForeignKey(related_name='abilityflavortext_language', blank=True, to='pokemon_v2.Language', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='encounter',
name='version',
field=models.ForeignKey(related_name='encounter', blank=True, to='pokemon_v2.Version', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='generation',
name='region',
field=models.ForeignKey(related_name='generation', blank=True, to='pokemon_v2.Region', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='generationname',
name='generation',
field=models.ForeignKey(related_name='generationname', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='location',
name='region',
field=models.ForeignKey(related_name='location', blank=True, to='pokemon_v2.Region', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='locationareaencounterrate',
name='version',
field=models.ForeignKey(related_name='locationareaencounterrate', blank=True, to='pokemon_v2.Version', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='move',
name='generation',
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='move',
name='type',
field=models.ForeignKey(related_name='move', blank=True, to='pokemon_v2.Type', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='moveeffectchange',
name='version_group',
field=models.ForeignKey(related_name='moveeffectchange', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='pokemonitem',
name='version',
field=models.ForeignKey(related_name='pokemonitem', blank=True, to='pokemon_v2.Version', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='pokemonspecies',
name='generation',
field=models.ForeignKey(related_name='pokemonspecies', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='type',
name='generation',
field=models.ForeignKey(related_name='type', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='version',
name='version_group',
field=models.ForeignKey(related_name='version', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='versiongroup',
name='generation',
field=models.ForeignKey(related_name='versiongroup', blank=True, to='pokemon_v2.Generation', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='versiongroupregion',
name='version_group',
field=models.ForeignKey(related_name='versiongroupregion', blank=True, to='pokemon_v2.VersionGroup', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='typeefficacy',
name='damage_type',
field=models.ForeignKey(related_name='damage_type', blank=True, to='pokemon_v2.Type', null=True),
preserve_default=True,
),
migrations.AddField(
model_name='typeefficacy',
name='target_type',
field=models.ForeignKey(related_name='target_type', blank=True, to='pokemon_v2.Type', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='pokemon',
name='pokemon_species',
field=models.ForeignKey(related_name='pokemon', blank=True, to='pokemon_v2.PokemonSpecies', null=True),
preserve_default=True,
),
migrations.AlterField(
model_name='pokemondexnumber',
name='pokedex',
field=models.ForeignKey(related_name='pokemondexnumber', blank=True, to='pokemon_v2.Pokedex', null=True),
preserve_default=True,
),
]

View file

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('pokemon_v2', '0004_auto_20150915_0448'),
]
operations = [
migrations.AlterField(
model_name='pokemonshapename',
name='pokemon_shape',
field=models.ForeignKey(related_name='pokemonshapename', blank=True, to='pokemon_v2.PokemonShape', null=True),
preserve_default=True,
),
]

View file

@ -1314,7 +1314,7 @@ class PokemonShapeName(IsName):
awesome_name = models.CharField(max_length = 30)
pokemon_shape = models.ForeignKey(PokemonShape, blank=True, null=True)
pokemon_shape = models.ForeignKey(PokemonShape, blank=True, null=True, related_name="pokemonshapename")
class PokemonStat(HasPokemon, HasStat):

View file

@ -98,6 +98,35 @@ class GenerationDetailSerializer(serializers.ModelSerializer):
fields = ('id', 'name', 'region', 'names')
############################
# GENERATION SERIALIZERS #
############################
class GrowthRateDescriptionSerializer(serializers.ModelSerializer):
language = LanguageSummarySerializer()
class Meta:
model = GrowthRateDescription
fields = ('description', 'language')
class GrowthRateSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = GrowthRate
fields = ('name', 'url')
class GrowthRateDetailSerializer(serializers.ModelSerializer):
descriptions = GrowthRateDescriptionSerializer(many=True, read_only=True, source="growthratedescription")
class Meta:
model = GrowthRate
fields = ('id', 'name', 'formula', 'descriptions')
#########################
# VERSION SERIALIZERS #
#########################
@ -288,10 +317,113 @@ class TypeDetailSerializer(serializers.ModelSerializer):
######################
# MOVE SERIALIZERS #
######################
class MoveNameSerializer(serializers.ModelSerializer):
language = LanguageSummarySerializer()
class Meta:
model = AbilityName
fields = ('name', 'language')
class MoveSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Move
fields = ('name', 'url')
class MoveDetailSerializer(serializers.ModelSerializer):
names = MoveNameSerializer(many=True, read_only=True, source="movename")
class Meta:
model = Move
fields = ('id', 'name', 'names')
#########################
# POKEMON SERIALIZERS #
#########################
class PokemonColorNameSerializer(serializers.HyperlinkedModelSerializer):
language = LanguageSummarySerializer()
class Meta:
model = PokemonColorName
fields = ('name', 'language')
class PokemonColorSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PokemonColor
fields = ('name', 'url')
class PokemonColorDetailSerializer(serializers.ModelSerializer):
names = PokemonColorNameSerializer(many=True, read_only=True, source="pokemoncolorname")
class Meta:
model = PokemonColor
fields = ('id', 'name', 'names')
class PokemonShapeNameSerializer(serializers.HyperlinkedModelSerializer):
language = LanguageSummarySerializer()
class Meta:
model = PokemonShapeName
fields = ('name', 'awesome_name', 'language')
class PokemonShapeSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PokemonShape
fields = ('name', 'url')
class PokemonShapeDetailSerializer(serializers.ModelSerializer):
names = serializers.SerializerMethodField('get_shape_names')
awesome_names = serializers.SerializerMethodField('get_shape_awesome_names')
class Meta:
model = PokemonShape
fields = ('id', 'name', 'names', 'awesome_names')
def get_shape_names(self, obj):
results = PokemonShapeName.objects.filter(pokemon_shape_id=obj)
serializer = PokemonShapeNameSerializer(results, many=True, context=self.context)
data = serializer.data
for entry in data:
del entry['awesome_name']
return data
def get_shape_awesome_names(self, obj):
results = PokemonShapeName.objects.filter(pokemon_shape_id=obj)
serializer = PokemonShapeNameSerializer(results, many=True, context=self.context)
data = serializer.data
for entry in data:
del entry['name']
return data
class PokemonSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
@ -305,10 +437,95 @@ class PokemonDetailSerializer(serializers.ModelSerializer):
model = Pokemon
class PokemonSpeciesNameSerializer(serializers.ModelSerializer):
language = LanguageSummarySerializer()
class Meta:
model = PokemonSpeciesName
fields = ('name', 'genus', 'language')
class PokemonSpeciesSummarySerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = PokemonSpecies
fields = ('name', 'url')
class PokemonSpeciesDetailSerializer(serializers.ModelSerializer):
names = serializers.SerializerMethodField('get_pokemon_names')
genera = serializers.SerializerMethodField('get_pokemon_genera')
generation = GenerationSummarySerializer()
growth_rate = GrowthRateSummarySerializer()
pokemon_color = PokemonColorSummarySerializer()
pokemon_shape = PokemonShapeSummarySerializer()
varieties = PokemonDetailSerializer(many=True, read_only=True, source="pokemon")
# types = TypeSummarySerializer(many=True, read_only=True, source="pokemonspecies")
class Meta:
model = PokemonSpecies
fields = (
'id',
'name',
'order',
'gender_rate',
'capture_rate',
'base_happiness',
'is_baby',
'hatch_counter',
'has_gender_differences',
'forms_switchable',
'growth_rate',
'pokemon_color',
'pokemon_shape',
'evolves_from_species',
'evolution_chain',
'pokemon_habitat',
'generation',
# 'types',
'names',
'genera',
'varieties'
)
def get_pokemon_names(self, obj):
results = PokemonSpeciesName.objects.filter(pokemon_species=obj)
serializer = PokemonSpeciesNameSerializer(results, many=True, context=self.context)
data = serializer.data
for name in data:
del name['genus']
return data
def get_pokemon_genera(self, obj):
results = PokemonSpeciesName.objects.filter(pokemon_species=obj)
serializer = PokemonSpeciesNameSerializer(results, many=True, context=self.context)
data = serializer.data
genera = []
for entry in data:
if entry['genus']:
del entry['name']
genera.append(entry)
return genera
# def get_pokemon_types()
class PokemonDexNumberSerializer(serializers.ModelSerializer):
entry_number = serializers.IntegerField(source="pokedex_number")
pokemon = PokemonSpeciesSummarySerializer(source="pokemon_species")
class Meta:
model = PokemonDexNumber
fields = ('pokedex', 'entry_number', 'pokemon')
@ -341,12 +558,11 @@ class PokedexDetailSerializer(serializers.ModelSerializer):
region = RegionSummarySerializer()
names = serializers.SerializerMethodField('get_pokedex_names')
descriptions = serializers.SerializerMethodField('get_pokedex_descriptions')
# pokemon = PokemonDexNumberSerializer(many=True, read_only=True, source="pokedex")
pokemon = serializers.SerializerMethodField('get_pokedex_entries')
pokemon_entries = serializers.SerializerMethodField('get_pokedex_entries')
class Meta:
model = Pokedex
fields = ('id', 'name', 'is_main_series', 'region', 'names', 'descriptions', 'pokemon')
fields = ('id', 'name', 'is_main_series', 'region', 'names', 'descriptions', 'pokemon_entries')
def get_pokedex_names(self, obj):
@ -363,7 +579,7 @@ class PokedexDetailSerializer(serializers.ModelSerializer):
results = PokedexDescription.objects.filter(pokedex_id=obj)
serializer = PokedexDescriptionSerializer(results, many=True, context=self.context)
data = serializer.data
data = serializer.data
for name in data:
del name['name']
@ -372,10 +588,16 @@ class PokedexDetailSerializer(serializers.ModelSerializer):
def get_pokedex_entries(self, obj):
results = PokemonDexNumber.objects.filter(pokedex=obj)
serializer = PokemonDexNumberSerializer(results, many=True, context=self.context)
return serializer.data
print obj
results = PokemonDexNumber.objects.order_by('pokedex_number').filter(pokedex=obj)
serializer = PokemonDexNumberSerializer(results, many=True, context=self.context)
data = serializer.data
for entry in data:
del entry['pokedex']
return data
#######################
@ -444,14 +666,6 @@ class LocationSerializer(serializers.ModelSerializer):
"""
class Meta:
model = Location
class MoveSerializer(serializers.ModelSerializer):
"""
Serializer for the Move resource
"""
class Meta:
model = Move
class NatureSerializer(serializers.ModelSerializer):

View file

@ -72,6 +72,14 @@ class GenerationResource(PokeapiCommonViewset):
serializer_class = GenerationDetailSerializer
list_serializer_class = GenerationSummarySerializer
class GrowthRateResource(PokeapiCommonViewset):
queryset = GrowthRate.objects.all()
serializer_class = GrowthRateDetailSerializer
list_serializer_class = GrowthRateSummarySerializer
class LanguageResource(PokeapiCommonViewset):
queryset = Language.objects.all()
@ -81,7 +89,8 @@ class LanguageResource(PokeapiCommonViewset):
class MoveResource(PokeapiCommonViewset):
queryset = Move.objects.all()
serializer_class = MoveSerializer
serializer_class = MoveDetailSerializer
list_serializer_class = MoveSummarySerializer
class NatureResource(PokeapiCommonViewset):
@ -97,11 +106,25 @@ class PokedexResource(PokeapiCommonViewset):
list_serializer_class = PokedexSummarySerializer
class PokemonColorResource(PokeapiCommonViewset):
queryset = PokemonColor.objects.all()
serializer_class = PokemonColorDetailSerializer
list_serializer_class = PokemonColorSummarySerializer
class PokemonShapeResource(PokeapiCommonViewset):
queryset = PokemonShape.objects.all()
serializer_class = PokemonShapeDetailSerializer
list_serializer_class = PokemonShapeSummarySerializer
class PokemonResource(PokeapiCommonViewset):
queryset = Pokemon.objects.all()
serializer_class = PokemonDetailSerializer
list_serializer_class =PokemonSummarySerializer
queryset = PokemonSpecies.objects.all()
serializer_class = PokemonSpeciesDetailSerializer
list_serializer_class =PokemonSpeciesSummarySerializer
class RegionResource(PokeapiCommonViewset):