1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.8.x] Fixed #24381 -- removed ForeignObjectRel opts and to_opts

These cached properies were causing problems with pickling, and in
addition they were confusingly defined: field.rel.model._meta was
not the same as field.rel.opts.

Instead users should use field.rel.related_model._meta inplace of
field.rel.opts, and field.rel.to._meta in place of field.rel.to_opts.

Backport of f95122e541 from master
This commit is contained in:
Anssi Kääriäinen
2015-02-23 09:31:58 +02:00
committed by Tim Graham
parent 980dfca717
commit 155a127afb
3 changed files with 14 additions and 15 deletions

View File

@@ -316,7 +316,7 @@ def label_for_field(name, model, model_admin=None, return_attr=False):
label = field.verbose_name
except AttributeError:
# field is likely a ForeignObjectRel
label = field.opts.verbose_name
label = field.related_model._meta.verbose_name
except FieldDoesNotExist:
if name == "__unicode__":
label = force_text(model._meta.verbose_name)