How can I get access to a Django Model field verbose name dynamically?
问题 I'd like to have access to one my model field verbose_name. I can get it by the field indice like this model._meta._fields()[2].verbose_name but I need to get it dynamically. Ideally it would be something like this model._meta._fields()['location_x'].verbose_name I've looked at a few things but I just can't find it. 回答1: For Django < 1.10: model._meta.get_field_by_name('location_x')[0].verbose_name 回答2: model._meta.get_field('location_x').verbose_name 回答3: For Django 1.11 and 2.0: MyModel.