pinax-models icon indicating copy to clipboard operation
pinax-models copied to clipboard

Deletion flag ignored when filtering from another model

Open reverie opened this issue 13 years ago • 3 comments

When a queryset is created from model A, but references model B, deleted instances of model B should be ignored. Instead, they are included.

For example, Parent.objects.filter(child__name='foo') will still return the parents with deleted children named "foo".

(Is there a good workaround for this?)

reverie avatar Oct 31 '12 21:10 reverie

use_for_related_fields should be set to true when setting the manager. This can be done in the provided abstract model.

Source: https://docs.djangoproject.com/en/dev/topics/db/managers/#using-managers-for-related-object-access

silvenepistola avatar Nov 05 '13 13:11 silvenepistola

How to emulate cascading behaviour in this situation. For example, if object is marked as deleted, than all objects that related to it also should be marked as deleted for consistency ?

Rustem avatar Feb 18 '15 07:02 Rustem

I believe this https://github.com/pinax/pinax-models/pull/11 would fix this behaviour since it uses django admin internal way of getting related models to delete (or not)

psychok7 avatar Aug 05 '15 11:08 psychok7