﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
17746	use_for_related_fields=False is not honored for m2m relation	mgagne_98@…	nobody	"Considering the following model: Trip <-> TripDestination <-> Destination (many to many relation). When I delete a Trip, the SoftDeleteManager filters out all the deleted trip. However, if I request all the destinations of a trip (using get_object_or_404(Trip, pk = id)), I also get the deleted ones (i.e. TripDestination models with deleted_at == null OR deleted_at != null). The SoftDeleteManager should have filtered it out.

'''Repro Steps'''

{{{
class SoftDeleteManager(models.Manager):
    use_for_related_fields = True

    def get_query_set(self):
        query_set = super(SoftDeleteManager, self).get_query_set()
        return query_set.filter(deleted_at__isnull = True)

class LifeTimeTrackingModel(models.Model):
    created_at = models.DateTimeField(auto_now_add = True)
    updated_at = models.DateTimeField(auto_now = True)
    deleted_at = models.DateTimeField(null = True)

    objects = SoftDeleteManager()
    all_objects = models.Manager()

    class Meta:
        abstract = True

class Destination(LifeTimeTrackingModel):
    city_name = models.CharField(max_length = 45)

class Trip(LifeTimeTrackingModel):
    name = models.CharField(max_length = 250)
    destinations = models.ManyToManyField(Destination, through = 'TripDestination')

class TripDestination(LifeTimeTrackingModel):
    trip = models.ForeignKey(Trip)
    destination = models.ForeignKey(Destination)
}}}


- Create a new Trip object with deleted_at set to null
- Create a new Destination object with deleted_at set to null
- Create a new TripDestination object with deleted_at set to datetime.now() linking the previously created Trip and Destionation objects

'''Actual Result'''
- Trip.objects.destinations returns the Destination objects

'''Expected Result'''
- Trip.objects.destinations shouldn't returns the Destination objects due to the SoftDeleteManager logic which should have filter it out

'''Other'''
http://stackoverflow.com/questions/9374962/how-to-soft-delete-many-to-many-relation-with-django"	Bug	closed	Database layer (models, ORM)	1.3	Normal	duplicate	use_for_related_fields m2m		Unreviewed	0	0	0	0	0	0
