Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
@brosner brosner authored
Showing with 8 additions and 7 deletions.
  1. +8 −7 django/contrib/admin/templatetags/admin_modify.py
View
15 django/contrib/admin/templatetags/admin_modify.py
@@ -8,13 +8,14 @@ def prepopulated_fields_js(context):
the prepopulated fields for both the admin form and inlines.
"""
prepopulated_fields = []
- if context["add"]:
- prepopulated_fields.extend(context["adminform"].prepopulated_fields)
- for inline_admin_formset in context['inline_admin_formsets']:
- for inline_admin_form in inline_admin_formset:
- if inline_admin_form.original is None:
- prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
- context.update({"prepopulated_fields": prepopulated_fields})
+ if context['add'] and 'adminform' in context:
+ prepopulated_fields.extend(context['adminform'].prepopulated_fields)
+ if 'inline_admin_formsets' in context:
+ for inline_admin_formset in context['inline_admin_formsets']:
+ for inline_admin_form in inline_admin_formset:
+ if inline_admin_form.original is None:
+ prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
+ context.update({'prepopulated_fields': prepopulated_fields})
return context
prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)

0 comments on commit 2193040

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