﻿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
36846	ContentType.get_object_for_this_type() raises inappropriate exception type for removed models	Maarten ter Huurne	Nilesh Pahari	"When asked for an object for which the model no longer exists, `ContentType.get_object_for_this_type()` will raise this exception:
{{{
AttributeError: 'NoneType' object has no attribute '_base_manager'
}}}

The reason for this is that the `model_class()` method will return `None` when the model cannot be found and the implementation of `get_object_for_this_type()` does not check for that:
{{{#!python
return self.model_class()._base_manager.using(using).get(**kwargs)
}}}

The behavior I'd expect is that `ObjectDoesNotExist` would be raised, similar to the situation where the model does exist but the object does not.

I first noticed this bug in Django 4.2.27, but the latest code in Git has the same issue.

If raising `ObjectDoesNotExist` is indeed the desired solution, I can provide a patch for that."	Cleanup/optimization	assigned	contrib.contenttypes	dev	Normal			Maarten ter Huurne	Accepted	0	0	0	0	0	0
