verbose_name is capitalized and goes against user expectations
afparsons opened this issue · 3 comments
In the following block in docstrings.py
, .capitalize()
is applied to the verbose_name
.
for field in obj._meta.get_fields():
try:
help_text = strip_tags(force_text(field.help_text))
verbose_name = force_text(field.verbose_name).capitalize()
except AttributeError:
# e.g. ManyToOneRel
continue
This is not behavior I expect as a user.
For example, I have a model and field:
class Configuration(models.Model):
api_secret_key = models.CharField(
max_length=32,
blank=False,
null=False,
verbose_name='API Secret Key',
)
I have explicitly set my preferred case (notably, all uppercase letters for the "API" abbreviation), but because .capitalize()
is applied to verbose_name
, this is turned into:
Api secret key
Solution proposals:
- remove
.capitalize()
entirely (and update test cases) - add configuration option to enable or disable
.capitalize()
This bothered me as well, I solved it in the following way:
field_verbose_name[:1].upper() + field_verbose_name[1:]
Since this project is not maintained anymore, I packaged my own fork: https://pypi.org/project/sphinxcontrib-django2/
If you have any ideas for improvements, feel free to submit them to the forked repo: sphinxcontrib-django2
Thanks, @timoludwig. I saw your "Maintained Fork" issue. While it is unfortunate that @vdboor has seemingly abandoned maintence, I'm glad you've stepped up and are willing to maintain a fork. Hopefully your fork gets more traction.
I now merged the changes of my fork back into this repo, including commit 7142309 which fixes this issue.