I want to define an @property once and use it on two different models. Is this possible?
Example:
Suppose I have two models, seller and buyer:
class seller(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
class buyer(models.Model):
first_name = models.CharField(max_length=50)
last_name = models.CharField(max_length=50)
And I wish to add a property for the django admin interface to display both models:
@property
def display_name(self):
return f"{first_name} {last_name}"
Is there a way to define this property once, but use it for both models?