Django

Code

Changeset 601

Show
Ignore:
Timestamp:
09/02/05 11:34:14 (3 years ago)
Author:
adrian
Message:

Fixed bug in has_related_links=True, which is legacy and shouldn't be used by anybody

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/core/meta/__init__.py

    r579 r601  
    300300            if self.has_related_links: 
    301301                # Manually add RelatedLink objects, which are a special case. 
    302                 core = get_module('relatedlinks', 'relatedlinks') 
     302                relatedlinks = get_module('relatedlinks', 'relatedlinks') 
    303303                # Note that the copy() is very important -- otherwise any 
    304304                # subsequently loaded object with related links will override this 
    305305                # relationship we're adding. 
    306                 link_field = copy.copy(core.RelatedLink._meta.get_field('object_id')) 
     306                link_field = copy.copy(relatedlinks.RelatedLink._meta.get_field('object_id')) 
    307307                link_field.rel = ManyToOne(self.get_model_module().Klass, 'id', 
    308308                    num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR, 
    309309                    lookup_overrides={ 
    310310                        'content_type__package__label__exact': self.app_label, 
    311                         'content_type__python_module_name__exact': self.module_name 
     311                        'content_type__python_module_name__exact': self.module_name, 
     312                        'object_id__id__exact': None, 
    312313                    }) 
    313                 rel_objs.append((core.RelatedLink._meta, link_field)) 
     314                rel_objs.append((relatedlinks.RelatedLink._meta, link_field)) 
    314315            self._all_related_objects = rel_objs 
    315316            return rel_objs 
     
    15331534                    params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True) 
    15341535                # Related links are a special case, because we have to 
    1535                 # manually set the "content_type_id" field
     1536                # manually set the "content_type_id" and "object_id" fields
    15361537                if opts.has_related_links and rel_opts.module_name == 'relatedlinks': 
    15371538                    contenttypes_mod = get_module('core', 'contenttypes')