title: How to use django commands to feed a db with an external API?
body: <p>I'm learning django and I want to feed my django db with <a href="https://pokeapi.co" rel="nofollow noreferrer">https://pokeapi.co</a> API so i can make a drop down list on HTML with every pokemon name up to date.</p>
  
  <p>fetchnames.py</p>
  
  <pre><code>import requests as r
  
  
  def nameslist():
      payload = {'limit':809}
      listpokemons = []
      response = r.get('https://pokeapi.co/api/v2/pokemon', params=payload)
      pokemons = response.json()
      for line in pokemons['results']:
          listpokemons.append(line['name'])
      return listpokemons
  
  ### Function that request from API and returns a list of pokemon names (['Bulbassaur', 'Ivyssaur',...)
  </code></pre>
  
  <p>core_app/management/commands/queryapi.py</p>
  
  <pre><code>from core_app.models import TablePokemonNames
  from core_app.fetchnames import nameslist
  
  
  class FetchApi(BaseCommand):
      help = "Update DB with https://pokeapi.co/"
  
      def add_model_value(self):
          table = TablePokemonNames()
          table.names = nameslist()
          table.save()
  </code></pre>
  
  <p>core_app/models.py</p>
  
  <pre><code>class TablePokemonNames(models.Model):
      id = models.AutoField(primary_key=True)
      names = models.CharField(max_length=100)
  </code></pre>
  
  <p>i'm pretty sure that i'm missing a lot since i'm still learning to use django and i'm still confuse on how should i use django commands, but, i tried to make a django command with <code>nameslist()</code> function and nothing happend on the db, there is something wrong with using a list to feed a db?</p>