Can you change a field label in the Django Admin application?

前端 未结 5 962
甜味超标
甜味超标 2020-12-30 18:28

As the title suggests. I want to be able to change the label of a single field in the admin application. I\'m aware of the Form.field attribute, but how do I get my Model or

5条回答
  •  忘掉有多难
    2020-12-30 19:20

    If your field is a property (a method) then you should use short_description:

    class Person(models.Model):
        ...
    
        def address_report(self, instance):
            ...
        # short_description functions like a model field's verbose_name
        address_report.short_description = "Address"
    

提交回复
热议问题