5👍
✅
updated
field = self._meta.get_field('opposition_state')
value = self._get_FIELD_display(field)
2👍
To override get_FOO_display you need something like this:
field_name = models.PositiveSmallIntegerField('Field', choices=some_choices)
def _get_FIELD_display(self, field):
f_name = field.name
if f_name == 'field_name':
return 'what_you_need'
return super(YourModelName, self)._get_FIELD_display(field=field)
- [Django]-How to set a login cookie in django?
- [Django]-Django Oauth Toolkit 2-legged and 3-legged
- [Django]-Django tables 2: Hyperlinking items in a column
- [Django]-POSTing foreign keys to Django Rest Framework, using Postman
Source:stackexchange.com