How to stop auto-capitalization of verbose_name in django

后端 未结 5 831
野趣味
野趣味 2021-01-03 06:45

How to prevent Django from auto-capitalizing of the verbose_name in models? E.g:

class TestModel(models.Model):
    enb_id = models.IntegerField(null=True, v         


        
5条回答
  •  庸人自扰
    2021-01-03 07:10

    It seems like the simple workaround for this is adding a whitespace at the beginning of verbose_name. Function that performs the capitalization (capfirst) changes only the first letter. If it is a whitespace nothing will be changed. Because web browsers ignore consecutive whitespaces everything will be displayed correctly.

    class TestModel(models.Model):
        enb_id = models.IntegerField(null=True, verbose_name=" eNB ID", blank=True)
    
        class Meta:
            verbose_name = " test model"
    

提交回复
热议问题