Thank you it is working. Wonderful
Andréas Kühne schrieb am Do., 31. Aug. 2023,
20:03:
> If you want the string instead of the value, you just use:
> entity.get_gender_display()
>
> Django automatically adds these "magic methods" when you have fields that
> have choices.
>
> You can see this in
If you want the string instead of the value, you just use:
entity.get_gender_display()
Django automatically adds these "magic methods" when you have fields that
have choices.
You can see this in the documentation:
https://docs.djangoproject.com/en/4.2/ref/models/fields/#choices
Regards,
Andréas
I have in my
model.py:
class GendersChoices(models.IntegerChoices):
M = 0, _('Male')
F = 1, _('Female')
N = 2, _('Gender Neutral')
class Address(models.Model):
gender = models.PositiveSmallIntegerField(choices=GendersChoices.choices,
blank=True, default=GendersChoices.F, null=True,
3 matches
Mail list logo