Skip to content

Commit

Permalink
added cached property on has_class_relation
Browse files Browse the repository at this point in the history
  • Loading branch information
PirosB3 committed Jun 26, 2014
1 parent 8dc041f commit 3bde9dc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions django/db/models/fields/related.py
Expand Up @@ -118,6 +118,7 @@ def _check_relation_model_exists(self):
]
return []

@cached_property
def has_class_relation(self):
return (hasattr(self, 'rel')
and self.rel
Expand Down
2 changes: 1 addition & 1 deletion django/db/models/options.py
Expand Up @@ -191,7 +191,7 @@ def get_new_fields(self, types, opts=NONE, **kwargs):
for model in self.non_swapped_models_auto_created:
for f in model._meta.get_new_fields(types=DATA | VIRTUAL, opts=INCLUDE_HIDDEN):
has_rel_attr = hasattr(f, 'rel') and f.rel
if has_rel_attr and f.has_class_relation():
if has_rel_attr and f.has_class_relation:
to_meta = f.rel.to._meta
if (to_meta == self) or ((opts & INCLUDE_PROXY)
and self.concrete_model == to_meta.concrete_model):
Expand Down

0 comments on commit 3bde9dc

Please sign in to comment.