﻿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
36158	get_and_report_namespace() incorrectly reports the location where an object was created.	Salvo Polizzi	Natalia Bidart	"When `get_and_report_namespace` is called with `verbosity=2`, it misreports the actual location where an object was created. This seems to happen because the function only considers objects with a `__module__` attribute. While this works correctly for functions and classes (which are defined in a module), it fails for instances. Since instances can be created elsewhere, the function incorrectly reports the module where the class was defined rather than where the instance was created.


== Steps to reproduce
1. Override `get_namespace()` using this [https://docs.djangoproject.com/en/dev/howto/custom-shell/#customizing-shell-auto-imports tutorial] as follows:
{{{
from django.core.management.commands import shell


class Command(shell.Command):
    def get_namespace(self):
        from django.db import connection
        return {
            ""connection"": connection,
        }
}}}

2. Start the Django shell with:
{{{
python manage.py shell -v 2
}}}

3. The output should report:
{{{
1 objects imported automatically, including:

  from django.utils.connection import connection
}}}
However, this is incorrect because connection is an instance, and it should report where it was actually created, not just the module where its class was defined.

"	Bug	closed	Core (Management commands)	5.2	Release blocker	fixed			Ready for checkin	1	0	0	0	0	0
