[Django] #30713: ListView queryset issue

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30713: ListView queryset issue

Django
#30713: ListView queryset issue
-------------------------------------+-------------------------------------
               Reporter:  Dmitrij    |          Owner:  nobody
  Strelnikov                         |
                   Type:  Bug        |         Status:  new
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:  queryset
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Hi guys,
 is this intentional behaviour or not?


 {{{
 class SomeQuerySet(models.QuerySet):
     def active(self):
         print('active')
         data = cache.get(CACHE_KEY)
         if data is None:
             print('no cache')
             data =
 self.select_related('related').filter(date_expired__gte=timezone.localtime().now()).filter(
                 some__is_active=True).order_by('-date_activated')
             cache.set(CACHE_KEY, data, 30)
         return data

 }}}


 {{{
 class QSSomeListView(ListView):
     queryset = Some.objects.active()
 }}}

 {{{
 class GetQSSomeListView(ListView):
     def get_queryset(self):
         return Some.objects.active()
 }}}

 QSSomeListView never print anything from `active()` method on page access,
 and actually never hit cache. It print only `active` once at project
 startup.

 GetQSSomeListView works as expected.

 If its intentional, could you please explain / point me why so?
 Thank you.

--
Ticket URL: <https://code.djangoproject.com/ticket/30713>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/053.8f38a77d6091772e093d82595ec6ddda%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30713: ListView queryset issue

Django
#30713: ListView queryset issue
-------------------------------------+-------------------------------------
     Reporter:  Dmitrij Strelnikov   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  queryset             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 Please don't use the issue tracker as a secondary support channel. See
 TicketClosingReasons/UseSupportChannels.

--
Ticket URL: <https://code.djangoproject.com/ticket/30713#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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.7dd750abe8bb4e90b4f327b2e102d448%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30713: ListView queryset issue

Django
In reply to this post by Django
#30713: ListView queryset issue
-------------------------------------+-------------------------------------
     Reporter:  Dmitrij Strelnikov   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:  queryset             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Dmitrij Strelnikov):

 * status:  closed => new
 * resolution:  invalid =>


Comment:

 Carlton, so you are telling this behaviour is not a bug?
 It's not support question, if so I would use stack overflow instead.
 Thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/30713#comment:2>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.3a4f9f96e4b8f003d210dec2078fb842%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30713: ListView queryset issue

Django
In reply to this post by Django
#30713: ListView queryset issue
-------------------------------------+-------------------------------------
     Reporter:  Dmitrij Strelnikov   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  queryset             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Claude Paroz):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 No, it's not a bug in Django. It's related to your `active()` method not
 being lazily evaluated. Please follow Carlton's advice.

--
Ticket URL: <https://code.djangoproject.com/ticket/30713#comment:3>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.8c58df04497a68b0be9c2196d226de91%40djangoproject.com.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30713: ListView queryset issue

Django
In reply to this post by Django
#30713: ListView queryset issue
-------------------------------------+-------------------------------------
     Reporter:  Dmitrij Strelnikov   |                    Owner:  nobody
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  2.2
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  invalid
     Keywords:  queryset             |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Dmitrij Strelnikov):

 thank you Claude, this was the thing I need to hear
 have a great day

--
Ticket URL: <https://code.djangoproject.com/ticket/30713#comment:4>
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/068.cafa5cf1d257a2d0606d87a8efa07f9c%40djangoproject.com.