What is the preferred way of storing generated content into file
models?
class Chart(models.Model):
xml = models.FileField(upload_to='charts')
...
I would like compute the image on the fly, using some data in the
database. How should I store the generated data? How should I use File
storage for this task?
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))
where data is a string, but that gives me
AttributeError: 'str' object has no attribute 'chunks'
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'
Should I use the class File directly? How? For File.save() to work, I
would need an associated an object. Please advise.
Thank you
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---