#32359: Should we define __round__ on Expression?
-------------------------------------+-------------------------------------
               Reporter:  Willem     |          Owner:  nobody
  Van Onsem                          |
                   Type:  New        |         Status:  new
  feature                            |
              Component:  Database   |        Version:  master
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  aggregates
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Rounding values can be done with:


 {{{
 from django.db.models.functions import Round

 Round(Count('related_model'))
 }}}

 But we could also implement the __round__ function on the Expression
 class, and thus use Python's round(...) function, then it thus no longer
 requires an import:

 {{{
 round(Count('related_model'))
 }}}

 A potential problem with this is that people might expect that this will
 itself return a number-like object, and not an expression.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32359>
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/052.32e3b567cdafb110c3b58cbeeb3afb9e%40djangoproject.com.

Reply via email to