mirror of https://github.com/django/django.git
Fixed #8353 -- Corrected the case when adminform is not in the context 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
This commit is contained in:
parent
15f8b4cde0
commit
219304019b
|
@ -8,13 +8,14 @@ def prepopulated_fields_js(context):
|
||||||
the prepopulated fields for both the admin form and inlines.
|
the prepopulated fields for both the admin form and inlines.
|
||||||
"""
|
"""
|
||||||
prepopulated_fields = []
|
prepopulated_fields = []
|
||||||
if context["add"]:
|
if context['add'] and 'adminform' in context:
|
||||||
prepopulated_fields.extend(context["adminform"].prepopulated_fields)
|
prepopulated_fields.extend(context['adminform'].prepopulated_fields)
|
||||||
for inline_admin_formset in context['inline_admin_formsets']:
|
if 'inline_admin_formsets' in context:
|
||||||
for inline_admin_form in inline_admin_formset:
|
for inline_admin_formset in context['inline_admin_formsets']:
|
||||||
if inline_admin_form.original is None:
|
for inline_admin_form in inline_admin_formset:
|
||||||
prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
|
if inline_admin_form.original is None:
|
||||||
context.update({"prepopulated_fields": prepopulated_fields})
|
prepopulated_fields.extend(inline_admin_form.prepopulated_fields)
|
||||||
|
context.update({'prepopulated_fields': prepopulated_fields})
|
||||||
return context
|
return context
|
||||||
prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
|
prepopulated_fields_js = register.inclusion_tag('admin/prepopulated_fields_js.html', takes_context=True)(prepopulated_fields_js)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue