Skip to content
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

Composable verbose names #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dokterbob
Copy link

Allow using parent names to dynamically compose verbose names of subfields, like so:

    class IntegerEstimatedRange(CompositeField):
        minimum = models.DurationField(
            lambda n: _("%(parent_verbose_name)s minimum") % {
                "parent_verbose_name": n
            }
        )

    class Species(models.Model):
        height = IntegerEstimatedRange(verbose_name=_("plant height"))

See proposed documentation. Test added for it as well.

@bikeshedder
Copy link
Owner

Sorry for taking so long. I almost forgot about this issue.

In the example of this issue you've used a lambda expression but the code just relies on formatting via the % operator.

I guess passing a lambda as verbose_name didn't work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants