I have three functions which I need in every Django Model:
def __unicode__(self):
return self.MODELNAME_name
def get_absolute_url(self):
return "/MODELNAME/list/"
def get_fields(self):
return [(field, field.value_to_string(self)) for field in MODELNAME._meta.fields]
The only thing different is the MODELNAME
How can I use inheritance so that I use three functions in one class and other inherit from it?
You could use multiple inheritance:
(Make sure you replace
MODELNAMEwithself.__class__.__name__)I did not test this, but it should work.