2👍
✅
The issue is that your __str__
method must return an object of type str
.
Since the index is what’s stored in self.region
, you can simply do a lookup:
class Region(models.Model):
...
def __str__(self):
return Region_CHOICES[self.region][1]
0👍
Just type cast to string
def __str__(self):
return str(self.region)
This works for me
Source:stackexchange.com