csvfile = StringIO.StringIO()
csvwriter = csv.writer(csvfile)
for leads in assigned_leads:
    csvwriter.writerow([leads.business_name, leads.first_name, leads.
        last_name, leads.email, leads.phone_number, leads.address, leads.
        city, leads.state, leads.zipcode, leads.submission_date, leads.
        time_frame, leads.comments])
message = EmailMessage('Hello', 'Your Leads', 'myemail@gmail.com', [
    'myemail@gmail.com'])
message.attach('invoice.csv', csvfile.getvalue(), 'text/csv')
Attach generated CSV file to email and send with Django