#23816: Ability to defer model field by default
----------------------------------------------+--------------------
Reporter: rcoup | Owner: nobody
Type: New feature | Status: new
Component: Database layer (models, ORM) | Version: master
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------------------------+--------------------
Today's small #IWantAPony is to be able to mark model fields as deferred
by default. No need to chase down every queryset and add `.defer()`, or
use a custom manager setup & remember to set `use_for_related_fields`.
{{{
class MyModel(models.Model):
enormous_field = models.TextField(defer=True)
other_field = models.IntegerField()
}}}
Which is (simplistically) equivalent to the following:
{{{
class MyManager(models.Manager):
use_for_related_fields = True
def get_queryset(self, *args, **kwargs):
return super(MyManager, self).get_queryset(*args,
**kwargs).defer("enormous_field")
class MyModel(models.Model):
enormous_field = models.TextField()
other_field = models.IntegerField()
objects = MyManager()
}}}
Obviously, you can still do `MyModel.objects.defer(None)` to do the full
query.
--
Ticket URL: <https://code.djangoproject.com/ticket/23816>
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/048.b2431797a899d9344c3972e6a0bfc3f3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.