1

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.

bogs
  • 2,286
  • 18
  • 22
  • Which part takes a long time? Showing the deletion confirmation page, or performing the delete? – Alasdair Sep 29 '15 at 11:24
  • Showing the deletion confirmation page. I believe it's the part of collecting related models. The deletion also takes long but just because probably the process of collecting related resources is repeated. – bogs Sep 29 '15 at 12:05

0 Answers0