Skip to content

Add @admin.display decorators in models file too #389

@UnknownPlatypus

Description

@UnknownPlatypus

Description

I think the display fixer doesn't support this use case from the docs:

  • A string representing a model attribute or method (without any required arguments).

Would be nice to have it work in that case too:

+from django.contrib import admin
from django.db import models

class Person(models.Model):
    name = models.CharField(max_length=50)
    birthday = models.DateField()

+   @admin.display(description='Birth decade')
    def decade_born_in(self):
        return '%d’s' % (self.birthday.year // 10 * 10)
-   decade_born_in.short_description = 'Birth decade'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions