1👍
to_field_name
changes the values of the generated option elements, not the display text.
You want to add a __str__
method to your model. It will change the display of each object instance listed in the select element.
Class Games(Model):
code = charField() # GTA, ABC, etc..
name = charField() # Grand Tourismo, ALL BBB CCC , etc..
unique_together(code, name)
def __str__(self):
return self.code
Source:stackexchange.com