'Initialises the field name -> field object mapping.'

def init_name_map(self):

    cache = {}
    for (f, model) in self.get_all_related_m2m_objects_with_model():
        cache[f.field.related_query_name()] = (f, model, False, True)
    for (f, model) in self.get_all_related_objects_with_model():
        cache[f.field.related_query_name()] = (f, model, False, False)
    for (f, model) in self.get_m2m_with_model():
        cache[f.name] = (f, model, True, True)
    for (f, model) in self.get_fields_with_model():
        cache[f.name] = (f, model, True, False)
    if app_cache_ready():
        self._name_map = cache
    return cache
