I'm encountering a strange issue with deferred fields in the Django admin. Here's how the model is structured.
class LightweightManager(models.Manager):
def get_query_set(self):
return super(LightweightManager, self).get_queryset()\
.defer('huge_field')\
.filter(trash=False)
class MyModel(models.Model):
# ...
huge_field = jsonfield.JSONField()
lightweight = LightweightManager()
def delete(self, using=None):
# ...
self.trash = True
When deleting a MyModel
from the admin, the web server timeouts. In the development server it finishes but takes very long obviously. On the delete confirmation admin page, I get a related model 'MyModel_ deferred_huge_field' (the deferred field). From what I can tell, there's something unusual happening in the django.db.models.deletion.Collector. I would be grateful for your suggestions.