From bde4c6d9955b2df78aed2f7ac540b017e4de3584 Mon Sep 17 00:00:00 2001 From: Brian Rosner Date: Mon, 19 Oct 2009 19:21:08 +0000 Subject: [1.1.X] Moved the call to _get_foreign_key to run in all cases catching incorrect inline setup sooner. Backport of [11631] from trunk git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.1.X@11633 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/admin/validation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'django') diff --git a/django/contrib/admin/validation.py b/django/contrib/admin/validation.py index 758090f896..595b951b9e 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -149,6 +149,9 @@ def validate(cls, model): validate_inline(inline, cls, 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 if cls.fk_name: # default value is None f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name) @@ -169,7 +172,6 @@ def validate_inline(cls, parent, parent_model): # exclude if hasattr(cls, 'exclude') and cls.exclude: - fk = _get_foreign_key(parent_model, cls.model, fk_name=cls.fk_name, can_fail=True) if fk and fk.name in cls.exclude: raise ImproperlyConfigured("%s cannot exclude the field " "'%s' - this is the foreign key to the parent model " -- cgit v1.3