#31558: Support the use of boolean attribute on properties in the admin.
------------------------------------+------------------------------------
Reporter: Alexandre Poitevin | Owner: nobody
Type: New feature | Status: new
Component: contrib.admin | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
------------------------------------+------------------------------------
Changes (by felixxm):
* type: Bug => New feature
* version: 3.0 => master
* stage: Unreviewed => Accepted
Old description:
> Example (adapted from the polls tutorial):
> {{{
> class Question(models.Model):
>
> DEFINITION_OF_RECENT = {"days": 1}
>
> text = models.CharField(max_length=255)
> publication_date = models.DateTimeField('Date of publication')
>
> @property
> def was_published_recently(self):
> timenow = timezone.now()
> recent = timenow - timedelta(**self.DEFINITION_OF_RECENT)
> return recent <= self.publication_date <= timenow
>
> was_published_recently.fget.admin_order_field = 'publication_date'
> was_published_recently.fget.short_description = 'Published Recently?'
> was_published_recently.fget.boolean = True
> }}}
>
> There is no problem with `short_description` nor `admin_order_filed`, but
> `boolean` does not act as expected.
>
> (I hesitated between Bug and New feature for this ticket…)
New description:
Example (adapted from the polls tutorial):
{{{
class Question(models.Model):
DEFINITION_OF_RECENT = {"days": 1}
text = models.CharField(max_length=255)
publication_date = models.DateTimeField('Date of publication')
def was_published_recently(self):
timenow = timezone.now()
recent = timenow - timedelta(**self.DEFINITION_OF_RECENT)
return recent <= self.publication_date <= timenow
was_published_recently.admin_order_field = 'publication_date'
was_published_recently.short_description = 'Published Recently?'
was_published_recently.boolean = True
was_published_recently = property(was_published_recently)
}}}
There is no problem with `short_description` nor `admin_order_filed`, but
`boolean` does not act as expected.
(I hesitated between Bug and New feature for this ticket…)
--
Comment:
Thanks. This is definitely a new feature (see similar ticket #30259 for
`admin_order_field` support). We can support it but when using the
`property()` function and not with decorator, that's why I updated the
ticket description.
--
Ticket URL: <https://code.djangoproject.com/ticket/31558#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/074.8adf9a69aef2e6cf2af9163ed4a782db%40djangoproject.com.