I am trying to do inheritance for a django model the following way:
from apps.main.models import Catalog class ExtendedModel(Catalog): class Meta: abstract = True def print_hello(self): print 'hello!!'
However, when I try and use that method, it says it is not found:
>>> from apps.main.models_master_extension import ExtendedModel >>> obj=ExtendedModel.objects.all() >>> obj <Catalog: 81758604> >>> obj.print_hello() Traceback (most recent call last): File "<console>", line 1, in <module> AttributeError: 'Catalog' object has no attribute 'print_hello'
What would be the correct way of extending the
Catalog class in another file? The reason I need to do this is that the methods involved in the
Catalog class extend 1000's of lines, and I want to separate some of them by function.