Answer the question
In order to leave comments, you need to log in
How to remove a field when inheriting a model?
How to remove an extra field when inheriting a django model, for example:
class Model1(models.Model):
product = models.ForeignKey('catalog.Product')
name = models.CharField()
comment = models.TextField()
comment_2 = models.TextField()
comment_3 = models.TextField()
created_at = models.DateTimeField(auto_now_add=True)
class Model2(Model1, models.Model):
product = None
comment_4 = models.TextField()
Answer the question
In order to leave comments, you need to log in
In no way, in this case, do not inherit from Model1, or take out the general in Model3, and inherit from it in Model1 and Model2, but in general it’s better to read what inheritance is in OOP and why it was invented, it’s the same as you inherit from a triangle from a square , like everything is the same, but you don’t need one coordinate, this is fundamentally not the right approach that will lead to many problems in the future
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question