Django - override base class model field on get

337 views Asked by At

I am using Django1.6

i have abstract class A, and class B:

class A(Model):
    att = CharField()

    class Meta:
        abstract = True

class B(A):
    pass

i want to override the behaviour of 'att' (without touching class A): so when using:

b = B(att='a').save()
b.att  (output is 'a')

but i want to override the output: so:

b.att (output is something else like 'a_thanks')

class B(A):
    @propert
    def att(self):
        return self._att + '_thanks'

how can i do it? i know this is possible from django 1.10

0

There are 0 answers