-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Titlise column verbose_name when derived from model #382
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
from django.utils import six | ||
from django.utils.html import escape, format_html | ||
|
||
from django_tables2.templatetags.django_tables2 import title | ||
from django_tables2.utils import AttributeDict | ||
|
||
from .base import Column, library | ||
|
@@ -58,6 +59,6 @@ def render(self, value, record, bound_column): | |
@classmethod | ||
def from_field(cls, field): | ||
if isinstance(field, models.BooleanField): | ||
return cls(verbose_name=field.verbose_name, null=False) | ||
return cls(verbose_name=title(field.verbose_name), null=False) | ||
if isinstance(field, models.NullBooleanField): | ||
return cls(verbose_name=field.verbose_name, null=True) | ||
return cls(verbose_name=title(field.verbose_name), null=True) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can move the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I just tried this and it failed a test. Unfortunately I don't think we simplify by extracting the title call. Do you want the title call assigned to a local variable before constructing the column class in these or was this note just for the booleancolumn since it had two calls and could potentially be simplified?
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it indeed makes sense to not move it up, let's keep it as is. Thanks for trying anyway! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add backticks around variable/property names here? i.e.: verbose_names ->
verbose_name
s