#22492: provide a way to prevent database queries on model objects
-------------------------------------+-------------------------------------
Reporter: cjerdonek | Owner: raulcd
Type: New feature | Status: assigned
Component: Database layer | Version: master
(models, ORM) |
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
model,queryset,defer,only |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by raulcd):
Is something like this a possible solution. I am thinking on the API, or
do we prefer a solution where we have a context manager?
{{{
In [1]: from polls.models import Choice
In [2]: p = Choice.objects.defer('body_yes', 'id')
In [3]: choice = p[0]
In [4]: choice.no_query_deferred = True
In [5]: choice.body_yes
Traceback (most recent call last):
File "<....>", line xxx, in <module>
QueryException: no_query flag is set to True and a query has been
attempted.
In [6]: choice.no_query_deferred = False
In [7]: choice.body_yes
Out[7]: u'yes'
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/22492#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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.5714efa5af5d9decd7c43dd5e89ae23f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.