Ticket #11448: patch.diff

File patch.diff, 885 bytes (added by josephdrose, 15 years ago)

Patch to rebuild cache if key error

  • options.py

     
    295295                cache = self.init_name_map()
    296296                return cache[name]
    297297        except KeyError:
    298             raise FieldDoesNotExist('%s has no field named %r'
     298            try:
     299                #Try to rebuild the cache and get the value again
     300                self._fill_fields_cache()
     301                self._fill_m2m_cache()
     302                self._fill_related_objects_cache()
     303                self._fill_related_many_to_many_cache()
     304                cache = self.init_name_map()
     305                return cache[name]
     306            except KeyError:
     307                raise FieldDoesNotExist('%s has no field named %r'
    299308                    % (self.object_name, name))
    300309
    301310    def get_all_field_names(self):
Back to Top