title: Django - Creating Models using a factory method
body: <p>I need to create those three models:</p>
  
  <pre><code>class Model_1(models.Model):
      def get_second_element(self):
          try:
              return Model_1.objects.all()[1]
          except:
              return None
  
  class Model_2(models.Model):
       def get_second_element(self):
          try:
              return Model_2.objects.all()[1]
          except:
              return None
  
  class Model_3(models.Model):
       def get_second_element(self):
          try:
              return Model_3.objects.all()[1]
          except:
              return None
  </code></pre>
  
  <p>How do I write a factory method that gets the name of the model to be created, and creates a model class with that name, and with the function get_second_element that query the DB of this model?</p>
  
  <p>Thanks.</p>