[Answer]-In Django, how to use a manager as default but not for related fields?

1👍

In this section the docs say the behavior is exactly what you want it to be.

The implementation also seems to do exactly what you want. 1.6 too.

Update:

If you don’t want to change every usage, then create subclass of ForeignKey, which uses subclass of ForeignRelatedObjectsDescriptor as a related_accessor_class with this method overwritten.

Pseudo code:

class PlainManagerForeignRelatedObjectDescriptor(ForeignRelatedObjectDescriptor):

    @cached_property
    def related_manager_cls(self):
        return create_foreign_related_manager(
            models.Manager,
            self.rel,
        )

class PlainManagerForeignKey(ForeignKEy):
    related_accessor_class = PlainManagerForeignRelatedObjectDescriptor

Leave a comment