I need to create a form for Player that has Role objects as choices in a dropdown field, but with their string field shown instead.
models.py
class Player(models.Model):
role = models.ForeignKey(role)
...
class Role(models.Model):
designation = models.CharField()
forms.py
class PlayerForm(ModelForm):
class Meta:
model = Player
fields = ['role']
Say I have three role objects with these as their designations, respectively: Warrior, Mage, Rouge, how can I display it in a PlayerForm instance as a dropdown, with no default value so the user has to choose one?
Currently this code displays the objects as the objects themselves (Role object (1), Role object (2), ...)