On Thu, Aug 28, 2008 at 11:44 AM, Jiri Barton <[EMAIL PROTECTED]> wrote: > I would like Django to take care of the file naming for me. I would > like to use a one-liner such as > > Chart.objects.create(xml=default_storage.save('data.xml', data))
You're nearly there for getting this to work, it's just the matter of how you're passing in the data. Try importing ContentFile from django.core.files.base, and using it like so: Chart.objects.create(xml=default_storage.save('data.xml', ContentFile(data))) > The example from > http://www.djangoproject.com/documentation/files/#storage-objects > does not work for me either: > >>>> from django.core.files.storage import default_storage > >>>> path = default_storage.save('/path/to/file', 'new content') > > This will give me > > <type 'exceptions.AttributeError'>: 'str' object has no attribute > 'chunks' Egad! Would you mind opening a ticket for this? That example is definitely wrong, and will need to be updated. -Gul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---