#31558: Boolean attribute for a property getter of a model doesn’t active the
“on/off” icon in the admin site
----------------------------------------------+------------------------
               Reporter:  Alexandre Poitevin  |          Owner:  nobody
                   Type:  Bug                 |         Status:  new
              Component:  contrib.admin       |        Version:  3.0
               Severity:  Normal              |       Keywords:
           Triage Stage:  Unreviewed          |      Has patch:  0
    Needs documentation:  0                   |    Needs tests:  0
Patch needs improvement:  0                   |  Easy pickings:  0
                  UI/UX:  0                   |
----------------------------------------------+------------------------
 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…)

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31558>
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/059.21963c1a2367f0754effb2b1e4886d73%40djangoproject.com.

Reply via email to