Skip to content

Commit

Permalink
fix(generic): run the columns names through pretty_name
Browse files Browse the repository at this point in the history
Make the column choices have the same format as the filter form labels
by running the field names through the `pretty_name` method.

Closes: #1028
  • Loading branch information
b1rger committed Nov 18, 2024
1 parent 4798c98 commit 07951c4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion apis_core/generic/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.contrib.auth.mixins import PermissionRequiredMixin
from django.core.exceptions import ImproperlyConfigured
from django.forms import modelform_factory
from django.forms.utils import pretty_name
from django.shortcuts import get_object_or_404, redirect
from django.template.exceptions import TemplateDoesNotExist
from django.template.loader import select_template
Expand Down Expand Up @@ -162,7 +163,7 @@ def get_filterset_class(self):
def _get_columns_choices(self, columns_exclude):
# we start with the model fields
choices = [
(field.name, getattr(field, "verbose_name", field.name))
(field.name, pretty_name(getattr(field, "verbose_name", field.name)))
for field in self.model._meta.get_fields()
]
# we add any annotated fields to that
Expand Down

0 comments on commit 07951c4

Please sign in to comment.