I am new to Python and Django platforms. I am trying to design a general class so that other classes can use the general class to create the same model type. To explain better, I give an example
Let’s say my general class is
class Person(models.Model):
name = models.CharField(max_length=20)
lastname=models.CharField(max_length=20)
job=models.CharField(max_length=20)
salary=models.IntegerField()
I want to have a exactly same table with Person class for each person that I create.
In my mind is something like that….
Class Person1(models.Model)
Person()
Class Person2(models.Model)
Person()
So, thus each person table will have same model type with Person class. Could you please help me how to do that? OR Is there a way to do that ?
I’m not sure I understand what you want or why you want that, but, I think the answer to your question is to use an Abstract Base Class.
Example: