Fixed #8957 -- Fixed incorrect error message when Admin prepopulated_fields refers to a field that does not exist. Thanks, charmless
git-svn-id: http://code.djangoproject.com/svn/django/trunk@9002 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
40cb11a554
commit
32db67e6f9
|
@ -120,8 +120,7 @@ def validate(cls, model):
|
||||||
def validate_inline(cls):
|
def validate_inline(cls):
|
||||||
# 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,
|
f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)
|
||||||
'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__)
|
||||||
|
@ -229,19 +228,15 @@ def validate_base(cls, model):
|
||||||
% (cls.__name__, field))
|
% (cls.__name__, field))
|
||||||
check_isseq(cls, "prepopulated_fields['%s']" % field, val)
|
check_isseq(cls, "prepopulated_fields['%s']" % field, val)
|
||||||
for idx, f in enumerate(val):
|
for idx, f in enumerate(val):
|
||||||
get_field(cls, model,
|
get_field(cls, model, opts, "prepopulated_fields['%s'][%d]" % (field, idx), f)
|
||||||
opts, "prepopulated_fields['%s'][%d]"
|
|
||||||
% (f, idx), f)
|
|
||||||
|
|
||||||
def check_isseq(cls, label, obj):
|
def check_isseq(cls, label, obj):
|
||||||
if not isinstance(obj, (list, tuple)):
|
if not isinstance(obj, (list, tuple)):
|
||||||
raise ImproperlyConfigured("'%s.%s' must be a list or tuple."
|
raise ImproperlyConfigured("'%s.%s' must be a list or tuple." % (cls.__name__, label))
|
||||||
% (cls.__name__, label))
|
|
||||||
|
|
||||||
def check_isdict(cls, label, obj):
|
def check_isdict(cls, label, obj):
|
||||||
if not isinstance(obj, dict):
|
if not isinstance(obj, dict):
|
||||||
raise ImproperlyConfigured("'%s.%s' must be a dictionary."
|
raise ImproperlyConfigured("'%s.%s' must be a dictionary." % (cls.__name__, label))
|
||||||
% (cls.__name__, label))
|
|
||||||
|
|
||||||
def get_field(cls, model, opts, label, field):
|
def get_field(cls, model, opts, label, field):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue