Ok, I've been looking all over the docs for a solution to this, but
there's a lot of documentation for the FileField, just not on how to
use it…

I have a model that looks like this:

class Import(models.Model):
    complete_data = models.FileField(upload_to='import_data/complete/
%Y/%m/')
    partial_data = models.FileField(upload_to='import_data/partial/%Y/
%m/')
    user = models.ForeignKey(User, blank=False, null=False)


I would like to do something like this:

import_data = Import.objects.create(user=user_object)
file_name = hashlib.sha1(user_object.username + str(time.time
())).hexdigest()
import_data.complete_data.name = file_name
import_data.complete_data.open('w')
import_data.complete_data.write(pickle.dumps(pickles))
import_data.complete_data.close()

But it seems these attributes are read-only… So, the golden question
is, how do I pick a file name and write to a FileField?
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to