#36066: Documentation about the use of Q objects inside of the annotate method
would be nice.
-------------------------------------+-------------------------------------
     Reporter:  Laurent Bergeron     |                     Type:
                                     |  Uncategorized
       Status:  new                  |                Component:  Database
                                     |  layer (models, ORM)
      Version:  5.1                  |                 Severity:  Normal
     Keywords:  documentation        |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  1                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
 I needed to annotate something to a queryset and found a solution that
 looked like this:
 {{{
 queryset = MyModel.objects.annotate(
     created_less_than_hour_ago=Q(time_of_creation__gt=(now() -
 timedelta(hours=1)))
 )
 }}}

 It worked fine and "created_less_than_hour_ago" was set to True if the
 object was created less than an hour ago and to False otherwise. I found
 another way to achieve this though because I didn't find any documentation
 about the use of Q objects inside of the annotate method, so I couldn't
 understand why and how it worked.

 So, here I am asking for documentation about it.
-- 
Ticket URL: <https://code.djangoproject.com/ticket/36066>
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 visit 
https://groups.google.com/d/msgid/django-updates/0107019438cf5f50-79d328db-d699-43af-b350-4af7b3de3fa4-000000%40eu-central-1.amazonses.com.

Reply via email to