diff options
| author | Tim Graham <timograham@gmail.com> | 2015-02-03 15:12:28 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-02-03 15:23:39 -0500 |
| commit | 0e489c19f1554ecfd9825daacfbac73be8ce723e (patch) | |
| tree | b975fe706d7a572d4421c7a926fe2b0e6eda6836 /django | |
| parent | 9ec8aa5e5d42ac4529846f7eae6bf4982800abff (diff) | |
Reverted "Fixed #24146 -- Fixed a missing fields regression in admin checks."
This reverts commit e8171daf0cd7f0e070395cb4c850c17fea32f11d.
A new solution is forthcoming.
Diffstat (limited to 'django')
| -rw-r--r-- | django/db/models/options.py | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/django/db/models/options.py b/django/db/models/options.py index 7daf756391..03470408e0 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -487,12 +487,6 @@ class Options(object): @cached_property def fields_map(self): - return self._get_fields_map() - - def _get_fields_map(self): - # Helper method to provide a way to access this without caching it. - # For example, admin checks run before the app cache is ready and we - # need to be able to lookup fields before we cache the final result. res = {} fields = self._get_fields(forward=False, include_hidden=True) for field in fields: @@ -537,26 +531,20 @@ class Options(object): return field except KeyError: - pass - - if m2m_in_kwargs: - # Previous API does not allow searching reverse fields. - raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name)) - - # If the app registry is not ready, reverse fields are probably - # unavailable, but try anyway. - if not self.apps.ready: - try: - # Don't cache results - return self._get_fields_map()[field_name] - except KeyError: + # If the app registry is not ready, reverse fields are + # unavailable, therefore we throw a FieldDoesNotExist exception. + if not self.apps.ready: raise FieldDoesNotExist( "%s has no field named %r. The app cache isn't ready yet, " - "so if this is an auto-created related field, it might not " + "so if this is an auto-created related field, it won't " "be available yet." % (self.object_name, field_name) ) try: + if m2m_in_kwargs: + # Previous API does not allow searching reverse fields. + raise FieldDoesNotExist('%s has no field named %r' % (self.object_name, field_name)) + # Retrieve field instance by name from cached or just-computed # field map. return self.fields_map[field_name] |
