Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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
  • Loading branch information...
commit 32db67e6f9c739b265f2860ffda42092bfa6b594 1 parent 40cb11a
Adrian Holovaty authored September 10, 2008

Showing 1 changed file with 4 additions and 9 deletions. Show diff stats Hide diff stats

  1. 13  django/contrib/admin/validation.py
13  django/contrib/admin/validation.py
@@ -120,8 +120,7 @@ def validate(cls, model):
120 120
 def validate_inline(cls):
121 121
     # model is already verified to exist and be a Model
122 122
     if cls.fk_name: # default value is None
123  
-        f = get_field(cls, cls.model, cls.model._meta,
124  
-                'fk_name', cls.fk_name)
  123
+        f = get_field(cls, cls.model, cls.model._meta, 'fk_name', cls.fk_name)
125 124
         if not isinstance(f, models.ForeignKey):
126 125
             raise ImproperlyConfigured("'%s.fk_name is not an instance of "
127 126
                     "models.ForeignKey." % cls.__name__)
@@ -229,19 +228,15 @@ def validate_base(cls, model):
229 228
                         % (cls.__name__, field))
230 229
             check_isseq(cls, "prepopulated_fields['%s']" % field, val)
231 230
             for idx, f in enumerate(val):
232  
-                get_field(cls, model,
233  
-                        opts, "prepopulated_fields['%s'][%d]"
234  
-                        % (f, idx), f)
  231
+                get_field(cls, model, opts, "prepopulated_fields['%s'][%d]" % (field, idx), f)
235 232
 
236 233
 def check_isseq(cls, label, obj):
237 234
     if not isinstance(obj, (list, tuple)):
238  
-        raise ImproperlyConfigured("'%s.%s' must be a list or tuple."
239  
-                % (cls.__name__, label))
  235
+        raise ImproperlyConfigured("'%s.%s' must be a list or tuple." % (cls.__name__, label))
240 236
 
241 237
 def check_isdict(cls, label, obj):
242 238
     if not isinstance(obj, dict):
243  
-        raise ImproperlyConfigured("'%s.%s' must be a dictionary."
244  
-                % (cls.__name__, label))
  239
+        raise ImproperlyConfigured("'%s.%s' must be a dictionary." % (cls.__name__, label))
245 240
 
246 241
 def get_field(cls, model, opts, label, field):
247 242
     try:

0 notes on commit 32db67e

Please sign in to comment.
Something went wrong with that request. Please try again.