mirror of
https://github.com/django/django.git
synced 2024-12-26 11:06:07 +00:00
Fixed bug in has_related_links=True, which is legacy and shouldn't be used by anybody
git-svn-id: http://code.djangoproject.com/svn/django/trunk@601 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
582e6a1010
commit
324f717c5e
@ -299,18 +299,19 @@ class Options:
|
|||||||
rel_objs.append((klass._meta, f))
|
rel_objs.append((klass._meta, f))
|
||||||
if self.has_related_links:
|
if self.has_related_links:
|
||||||
# Manually add RelatedLink objects, which are a special case.
|
# Manually add RelatedLink objects, which are a special case.
|
||||||
core = get_module('relatedlinks', 'relatedlinks')
|
relatedlinks = get_module('relatedlinks', 'relatedlinks')
|
||||||
# Note that the copy() is very important -- otherwise any
|
# Note that the copy() is very important -- otherwise any
|
||||||
# subsequently loaded object with related links will override this
|
# subsequently loaded object with related links will override this
|
||||||
# relationship we're adding.
|
# relationship we're adding.
|
||||||
link_field = copy.copy(core.RelatedLink._meta.get_field('object_id'))
|
link_field = copy.copy(relatedlinks.RelatedLink._meta.get_field('object_id'))
|
||||||
link_field.rel = ManyToOne(self.get_model_module().Klass, 'id',
|
link_field.rel = ManyToOne(self.get_model_module().Klass, 'id',
|
||||||
num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR,
|
num_in_admin=3, min_num_in_admin=3, edit_inline=TABULAR,
|
||||||
lookup_overrides={
|
lookup_overrides={
|
||||||
'content_type__package__label__exact': self.app_label,
|
'content_type__package__label__exact': self.app_label,
|
||||||
'content_type__python_module_name__exact': self.module_name
|
'content_type__python_module_name__exact': self.module_name,
|
||||||
|
'object_id__id__exact': None,
|
||||||
})
|
})
|
||||||
rel_objs.append((core.RelatedLink._meta, link_field))
|
rel_objs.append((relatedlinks.RelatedLink._meta, link_field))
|
||||||
self._all_related_objects = rel_objs
|
self._all_related_objects = rel_objs
|
||||||
return rel_objs
|
return rel_objs
|
||||||
|
|
||||||
@ -1532,7 +1533,7 @@ def manipulator_save(opts, klass, add, change, self, new_data):
|
|||||||
else:
|
else:
|
||||||
params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True)
|
params[f.column] = f.get_manipulator_new_data(rel_new_data, rel=True)
|
||||||
# Related links are a special case, because we have to
|
# Related links are a special case, because we have to
|
||||||
# manually set the "content_type_id" field.
|
# manually set the "content_type_id" and "object_id" fields.
|
||||||
if opts.has_related_links and rel_opts.module_name == 'relatedlinks':
|
if opts.has_related_links and rel_opts.module_name == 'relatedlinks':
|
||||||
contenttypes_mod = get_module('core', 'contenttypes')
|
contenttypes_mod = get_module('core', 'contenttypes')
|
||||||
params['content_type_id'] = contenttypes_mod.get_object(package__label__exact=opts.app_label, python_module_name__exact=opts.module_name).id
|
params['content_type_id'] = contenttypes_mod.get_object(package__label__exact=opts.app_label, python_module_name__exact=opts.module_name).id
|
||||||
|
Loading…
Reference in New Issue
Block a user