Re: Django Resolve Choices Class

2023-08-31 Thread Sebastian Jung
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

Re: Django Resolve Choices Class

2023-08-31 Thread Andréas Kühne
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

Django Resolve Choices Class

2023-08-30 Thread sebasti...@gmail.com
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,