1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

[1.5.x] Fixed #19545 -- Make sure media/is_multipart work with empty formsets

Backport of 3fc43c964e from master.
This commit is contained in:
Simon Charette
2013-01-03 15:13:51 +01:00
committed by Claude Paroz
parent be1e006c58
commit 70cc95d1cc
2 changed files with 21 additions and 5 deletions

View File

@@ -333,7 +333,10 @@ class BaseFormSet(object):
Returns True if the formset needs to be multipart, i.e. it
has FileInput. Otherwise, False.
"""
return self.forms and self.forms[0].is_multipart()
if self.forms:
return self.forms[0].is_multipart()
else:
return self.empty_form.is_multipart()
@property
def media(self):
@@ -342,7 +345,7 @@ class BaseFormSet(object):
if self.forms:
return self.forms[0].media
else:
return Media()
return self.empty_form.media
def as_table(self):
"Returns this formset rendered as HTML <tr>s -- excluding the <table></table>."