Repository: wagtail/wagtail

Issue:
[BUG] Unexpected table header label modification
A small bug that converts all kinds of abbreviations within Snippets to titles. For instance "CPC Fee" becomes "Cpc Fee"

https://github.com/wagtail/wagtail/blob/c895e9031b2dfa7804ab131f5a991abcd5e9f11a/wagtail/admin/views/generic/models.py#L302


Discussion:
It is a little unclear how it should be fixed since we use `model_field.verbose_name` as labels and those are lowercased per django recommendations: https://docs.djangoproject.com/en/4.2/topics/db/models/#verbose-field-names
Thanks for reporting! As per the discussion on https://github.com/wagtail/wagtail/issues/9219, we should use Django's `capfirst` function here.
@gasman  can you assign this issue to me ?
Thanks for your interest @abhay-ahirkar! We do not assign issues outside of the core team - anyone is free to work on any issue. Now that you've expressed an interest, other people may choose to hold off on picking this up, but they are not required to.

We recommend thoroughly reading https://docs.wagtail.org/en/latest/contributing/first_contribution_guide.html before making your first contribution. You may also wish to join [our #new-contributors channel on Slack](https://github.com/wagtail/wagtail/wiki/Slack).
@gasman I'm not clear about this let me come with an example,
let label value be lABel so when we use capfirst it convets it into LABel 
or should it be just lABel 

Resolving patch:
diff --git a/wagtail/admin/views/generic/models.py b/wagtail/admin/views/generic/models.py
--- a/wagtail/admin/views/generic/models.py
+++ b/wagtail/admin/views/generic/models.py
@@ -10,6 +10,7 @@
 from django.urls import reverse
 from django.utils.translation import gettext as _
 from django.utils.translation import gettext_lazy
+from django.utils.text import capfirst
 from django.views.generic import TemplateView
 from django.views.generic.detail import BaseDetailView
 from django.views.generic.edit import BaseCreateView
@@ -299,7 +300,7 @@ def _get_custom_column(self, field_name, column_class=Column, **kwargs):
 
         return column_class(
             field_name,
-            label=label.title(),
+            label=capfirst(label),
             sort_key=sort_key,
             **kwargs,
         )


Test patch:
diff --git a/wagtail/snippets/tests/test_viewset.py b/wagtail/snippets/tests/test_viewset.py
--- a/wagtail/snippets/tests/test_viewset.py
+++ b/wagtail/snippets/tests/test_viewset.py
@@ -652,8 +652,8 @@ def get(self, params={}):
     def test_custom_columns(self):
         response = self.get()
         self.assertContains(response, "Text")
-        self.assertContains(response, "Country Code")
-        self.assertContains(response, "Custom Foo Column")
+        self.assertContains(response, "Country code")
+        self.assertContains(response, "Custom FOO column")
         self.assertContains(response, "Updated")
 
         self.assertContains(response, "Foo UK")
diff --git a/wagtail/test/testapp/models.py b/wagtail/test/testapp/models.py
--- a/wagtail/test/testapp/models.py
+++ b/wagtail/test/testapp/models.py
@@ -1135,7 +1135,7 @@ def get_foo_country_code(self):
         return f"Foo {self.country_code}"
 
     get_foo_country_code.admin_order_field = "country_code"
-    get_foo_country_code.short_description = "Custom foo column"
+    get_foo_country_code.short_description = "custom FOO column"
 
     class Meta(TranslatableMixin.Meta):
         verbose_name = "full-featured snippet"