Custom Model Prototypes, Is that Possible?

I am trying to create Models based on a prototype model but I do not want migrations to pick the prototype.

say, I have:

class Prototype(models.Model)
    prop = models.CharField(max_length=255)
    another = models.CharField(max_length=255)
    yet_another = models.CharField(max_length=255)

Now I want to make models after the above prototype like so:

class MyModel(Prototype):
    Class Meta:
        db_table = "custom_name"
class AnotherModel(Prototype):
    Class Meta:
        db_table = "another_name"

Is there a way to do this? My approach is not giving expected results because:

./manage.py makemigration --dry-run

tells me that Django is going to create a table for the Prototype as well. I just want tables for the instances and not the prototype. I also want each new instance to have a different name (but have same fields as the prototype).

Hi onyeibo,

Sounds like you want an abstract model: Models | Django documentation | Django :+1:

1 Like

Thank you very much. This is exactly what I was looking for