Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #8353 -- Corrected the case when adminform is not in the contex…

…t when rendering {% prepopulated_fields_js %} in the admin. Thanks evan_schulz for the initial patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@8421 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 219304019bff8360d802fa658757594fbc1a4155 1 parent 15f8b4c
Brian Rosner authored August 17, 2008
15  django/contrib/admin/templatetags/admin_modify.py
@@ -8,13 +8,14 @@ def prepopulated_fields_js(context):
8 8
     the prepopulated fields for both the admin form and inlines.
9 9
     """
10 10
     prepopulated_fields = []
11  
-    if context["add"]:
12  
-        prepopulated_fields.extend(context["adminform"].prepopulated_fields)
13  
-    for inline_admin_formset in context['inline_admin_formsets']:
14  
-        for inline_admin_form in inline_admin_formset:
15  
-            if inline_admin_form.original is None:
16  
-                prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
17  
-    context.update({"prepopulated_fields": prepopulated_fields})
  11
+    if context['add'] and 'adminform' in context:
  12
+        prepopulated_fields.extend(context['adminform'].prepopulated_fields)
  13
+    if 'inline_admin_formsets' in context:
  14
+        for inline_admin_formset in context['inline_admin_formsets']:
  15
+            for inline_admin_form in inline_admin_formset:
  16
+                if inline_admin_form.original is None:
  17
+                    prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
  18
+    context.update({'prepopulated_fields': prepopulated_fields})
18 19
     return context
19 20
 prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
20 21
 

0 notes on commit 2193040

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