On Jul 13, 9:28 am, Massimiliano della Rovere <massimiliano.dellarov...@gmail.com> wrote: > I need to "decode" the value of the fields of ModelAdmin.form so that, > for some fields, the int value is translated in a string showing its > meaning. > I do not want to implement this in the Model class (using > Model.to_python or Model.formfield for example), because the > information displayed in the columns of changelist_view page are > enough for the 90% of the times, so I prefer to do the extra work > necessary to generate the strings only when requested thus avoiding > the overhead necessary to select the correct string to be wasted in > most cases. > > So I was in doubt whether to override the ModelAdmin,get_form or some > _get_val_from_obj for some fields from the ModelAdmin.form. > > Which one is more correct in your opinion?
Couldn't you just use `choices` for that? Specify the possible values and their 'decoded' versions in a 2-tuple, set the field's choices parameter to that constant, and you would automatically get a `get_FOO_display()` method which would show the 'decoded' value instead of the original one. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.