#32660: Endless loop upon delete
-------------------------------------+-------------------------------------
     Reporter:  kr                   |                    Owner:  exec-life
         Type:  Uncategorized        |                   Status:  assigned
    Component:  Database layer       |                  Version:  3.1
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 Your code will break as soon as fields are deferred which is something
 model deletion does to instantiate model instances while reducing memory
 and CPU usage during cascade deletion.

 In other code your code breaks the `Bar.objects.defer('bar1)` pattern
 because accessing fields triggers loading which
 [https://docs.djangoproject.com/en/3.2/ref/models/instances/#customizing-
 model-loading is covered by the docs].

 This is detailed a bit in #31475 but I suggest you avoid overriding
 `__init__` and favour `from_db_value` and rely on `fields` instead of if
 you cannot do `self.__dict__.get('bar1')` to bypass deferred attributes
 descriptors.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/32660#comment:5>
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/060.61cc2a20e1f0d5b187893d445d7e1704%40djangoproject.com.

Reply via email to