Django modelFieldFieldField with choices, show value instead of key

0

I'm working with Django 1.10.6, I'm creating a modelForm with a CharField with a choices attribute:

model :

class myModel(models.Model, object):
    ASSIGNED = 'AS'
    NOT_ASSIGNED = 'NA'
    INVALID = 'IN'
    MIGRATED = 'MI'
    STATES = ((ASSIGNED, 'Asignada'), (NOT_ASSIGNED, 'No asignada'), (MIGRATED, 'Migrada'), (INVALID, 'Aceptada'))

    state = models.CharField(verbose_name="Estado", max_length=2, choices=STATES)
    ...

modelform :

class MifareCardMigrationAssignationForm(forms.ModelForm, object):
    ...
    state = forms.CharField(label="Estado", help_text="Estado de migración", disabled=True)
    ...

    class Meta:
        model = MifareCardMigration
        fields = ('legacy_number', 'plate', 'new_card', 'phone_number', 'state')

The problem I have when editing an object in the Django admin, in the field state I want to show its value , but its key appears .

How can I change this behavior ??

Thanks !!

    
asked by Lucho 30.10.2017 в 19:32
source

0 answers