#31582: Django template backend allocates model cache even iterator() is used
-------------------------------------------+------------------------
               Reporter:  sumerc           |          Owner:  nobody
                   Type:  Bug              |         Status:  new
              Component:  Template system  |        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                |
-------------------------------------------+------------------------
 Hi,

 I was testing template engines with a memory profiler we have written and
 I have seen an interesting issue with Django template engine. Still not
 sure if this is an issue or intended.

 The database backend I use is django.db.backends.sqlite3. I am using
 following code to retrieve a huge list of objects:

 {{{
 comments = Comment.objects.all().iterator()
 template = loader.get_template('polls/comments.html')
 context = {
         'comments': comments,
     }
 return HttpResponse(template.render(context, request))
 }}}

 And the template code:

 {{{
 {% for comment in comments %}
     a
 {% endfor %}
 }}}

 When I ran the view, I see the
 {{{django.db.models.base.Comment.__init__}}} caches the results. If I
 change the TEMPLATE backend to {{{Jinja2}}} I verified it is not being
 cached.

 Is this somewhat intended behaviour? If so, how can we disable Model
 caching for Django templates?

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31582>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/049.848912c7c5202401206b5962d6ab80d1%40djangoproject.com.

Reply via email to