mirror of https://github.com/django/django.git
[3.1.x] Improved examples in ModelAdmin.list_display docs.
Backport of aa53655e6e
from master
This commit is contained in:
parent
1f6e7fb4ab
commit
4f11461195
|
@ -589,7 +589,7 @@ subclass::
|
||||||
birthday = models.DateField()
|
birthday = models.DateField()
|
||||||
|
|
||||||
def decade_born_in(self):
|
def decade_born_in(self):
|
||||||
return self.birthday.strftime('%Y')[:3] + "0's"
|
return '%d’s' % (self.birthday.year // 10 * 10)
|
||||||
decade_born_in.short_description = 'Birth decade'
|
decade_born_in.short_description = 'Birth decade'
|
||||||
|
|
||||||
class PersonAdmin(admin.ModelAdmin):
|
class PersonAdmin(admin.ModelAdmin):
|
||||||
|
@ -678,7 +678,7 @@ subclass::
|
||||||
birthday = models.DateField()
|
birthday = models.DateField()
|
||||||
|
|
||||||
def born_in_fifties(self):
|
def born_in_fifties(self):
|
||||||
return self.birthday.strftime('%Y')[:3] == '195'
|
return 1950 <= self.birthday.year < 1960
|
||||||
born_in_fifties.boolean = True
|
born_in_fifties.boolean = True
|
||||||
|
|
||||||
class PersonAdmin(admin.ModelAdmin):
|
class PersonAdmin(admin.ModelAdmin):
|
||||||
|
|
Loading…
Reference in New Issue