﻿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
32640	Non-manager instance assigned to model class' objects is silently  ignored	Shai Berger	Shai Berger	"Consider this models file:

{{{#!python
from django.db import models


class MyManager(models.Manager):
    def get_queryset(self):
        return self.none()


class MyModel(models.Model):
    one = models.IntegerField()

    objects = MyManager  # Note: Missing parentheses
}}}

The assignment of a manager class, rather than manager instance, is an easy mistake to make. I know, because I've made it. In a private discussion, Carlton Gibson suggested another variant of this:

{{{#!python
class MyOtherModel(models.Model):
    ...
    objects = models.Manager.from_queryset(SomeQueryset())
    # The above, too, is missing a pair of parentheses
}}}

But what should Django do?

There's two possible behaviors I would consider reasonable:
- Trust the user, and rely on Duck Typing. This would blow up very fast in this case, as any method invocation would be missing the {{{self}}} argument.
- Raise an error on model creation, or at least in {{{check}}}.

What Django does instead, is ignore the assignment and use a {{{models.Manager}}} instance.

Two points to clarify that this is indeed a bug:
- Assigning any object which isn't a {{{models.Manager}}} instance -- say, the number 17 -- gets the same result.
- This only happens if only one manager is defined. If another manager is defined, the assignment stands as written (the first ""reasonable"" behavior described above).

I found this on 2.2, it is still this way on master.
"	Bug	assigned	Database layer (models, ORM)	2.2	Normal			Carlton Gibson	Accepted	1	0	0	1	0	0
