1
0
mirror of https://github.com/django/django.git synced 2025-10-25 14:46:09 +00:00

Fixed #19545 -- Make sure media/is_multipart work with empty formsets

This commit is contained in:
Simon Charette
2013-01-03 15:13:51 +01:00
committed by Claude Paroz
parent 9b5f64cc6e
commit 3fc43c964e
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>."