# For generating ZIP files.
from StringIO import StringIO
from zipfile import ZipFile, ZIP_DEFLATED
import re
# Django-specific imports.
from django.http import HttpResponse
@@ -99,6 +100,11 @@ class IptablesView(DetailView):
# browser to download the file with suggested filename.
response['Content-Disposition']="attachment; filename=%s-iptables.conf" % self.object.name.lower().replace(" ", "_")
# Render the response, and remove the blank lines from the template.
response.render()
response.content = re.sub('^\s*\n', '', response.content)
response.content = re.sub('\n\s*\n', '\n', response.content)
# Return the modified response.
return response