mirror of
https://github.com/django/django.git
synced 2025-10-24 22:26:08 +00:00
Changed get_model to raise an exception on errors.
Returning None on errors required unpythonic error checking and was inconsistent with get_app_config. get_model was a private API until the previous commit, but given that it was certainly used in third party software, the change is explained in the release notes. Applied the same change to get_registered_model, which is a new private API introduced during the recent refactoring.
This commit is contained in:
@@ -188,8 +188,9 @@ class ModelDetailView(BaseAdminDocsView):
|
||||
apps.get_app_config(self.kwargs['app_label'])
|
||||
except LookupError:
|
||||
raise Http404(_("App %(app_label)r not found") % self.kwargs)
|
||||
model = apps.get_model(self.kwargs['app_label'], self.kwargs['model_name'])
|
||||
if model is None:
|
||||
try:
|
||||
model = apps.get_model(self.kwargs['app_label'], self.kwargs['model_name'])
|
||||
except LookupError:
|
||||
raise Http404(_("Model %(model_name)r not found in app %(app_label)r") % self.kwargs)
|
||||
|
||||
opts = model._meta
|
||||
|
||||
Reference in New Issue
Block a user