I'm having an issue passing a buffered StringIO to the FileField object. Here is my code:
##models.py from django.db import models from business.models import Business class PdfFile(models.Model): business = models.ForeignKey(Business) pdf = models.FileField(upload_to='get_pdf_path') created = models.DateTimeField(editable=False) ##console from cStringIO import StringIO from reportlab.pdfgen import canvas from pdf.models import PdfFile from business.models import Business from django.core.files.base import ContentFile from datetime import datetime buffer = StringIO() p = canvas.Canvas(buffer) p.drawString(100, 100, "Hello world.") p.showPage() p.save() business1 = business.objects.get(id=1) f = ContentFile(buffer.getvalue()) PdfFile.pdf.save('blah.pdf', f) ########################### I've tried this as well: path = default_storage.save('pdf/1/1.pdf', ContentFile(buffer.getvalue ())) test = PdfFile(listing = listing1,pdf=path, created = datetime.now()) test.save() The issue with thtis is that the path object actually creates the file and then when I pass it to save it actually sets the file to my media directory/test and doesn't name the pdf or even show the proper pdf dir. My goal is to pass my StringIO object directly to the FileField for upload to my upload_to dir... TIA --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---