title: How can I dynamically create objects in django/python?
body: <p>In my code I have many if/elif statements like this:</p>
  
  <pre><code>if type == "cat":
      vote = VoteCat (
          user = user,
          cat_id = thing_id )
      vote.save()
  elif type == "dog":
      vote = VoteDog (
          user = user,
          dog_id = thing_id )
      vote.save()
  </code></pre>
  
  <p>What would be a good way to change my code to get rid of the if statements and instantiate the object I need dynamically? The code I am hoping I can write would accomplish the same as above but look more like this:</p>
  
  <pre><code>AnimalVote = get_animalvote_by_type(type)
  AnimalVote.user = user
  AnimalVote.assign_animal_id(thing_id)
  AnimalVote.save()
  </code></pre>