I have overrode (overrided?) the get_FOO_display()
method of django model class (see: doc reference) to return some different choice field mapping. But, on calling this function from the django template as {{ model_object.get_FOO_display }}
calls the base class method instead of the new overridden method.
I read the source code django/db/models/base.py and it seems like this is not some regular method rather, it is created dynamically for the model fields. (let me know if am getting it wrong)
Is there a way I can resolve to the overridden method from the template ?
See this code to get the essence of my issue:
class UserStatus(models.Model):
invite_status = models.CharField(max_length=15, choices=USER_STATUS, default='new')
# Overridden method
def get_invite_status_display(self):
return dict(USER_STATUS_DISPLAY).get(self.invite_status)
Yes, I need to display different content than the choices
dict and no, I cannot keep my to-be-displayed content in the choice dict in the first place.
Let me know if there is any possible way to make this template call work.
Thanks.