From 6cbdbffc80fde098ed491dc2aea4d1f3105b3ad6 Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Fri, 23 Jun 2006 07:43:33 +0000 Subject: [PATCH] Added comments to clarify the string->field name resolution logic. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3196 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/db/models/fields/related.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 3863e75993..ad31a92c91 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -23,11 +23,14 @@ def add_lookup(rel_cls, field): name = field.rel.to module = rel_cls.__module__ key = (module, name) + # Has the model already been loaded? + # If so, resolve the string reference right away model = get_model(rel_cls._meta.app_label,field.rel.to) if model: field.rel.to = model field.do_related_class(model, rel_cls) else: + # Mark the related field for later lookup pending_lookups.setdefault(key, []).append((rel_cls, field)) def do_pending_lookups(sender):