Moved _get_foreign_key call after testing for fk_name fixing a broken test.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@11643 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Brian Rosner 2009-10-23 20:47:29 +00:00
parent fa6ca072a3
commit 0d1177ae99
1 changed files with 3 additions and 2 deletions

View File

@ -150,14 +150,15 @@ def validate(cls, model):
def validate_inline(cls, parent, parent_model): def validate_inline(cls, parent, parent_model):
fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
# model is already verified to exist and be a Model # model is already verified to exist and be a Model
if cls.fk_name: # default value is None if cls.fk_name: # default value is None
f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name) f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)
if not isinstance(f, models.ForeignKey): if not isinstance(f, models.ForeignKey):
raise ImproperlyConfigured("'%s.fk_name is not an instance of " raise ImproperlyConfigured("'%s.fk_name is not an instance of "
"models.ForeignKey." % cls.__name__) "models.ForeignKey." % cls.__name__)
fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True)
# extra = 3 # extra = 3
# max_num = 0 # max_num = 0
for attr in ('extra', 'max_num'): for attr in ('extra', 'max_num'):