Hello everybody, I'm developing an app for the first time with Django and I have a problem with upload path and UUID. I have a form with 3 fields for uploading text files. So I want to save those 3 files in the same directory which have a unique name. First I did this a big random number but if 2 requests are submitted almost at the same time I could generate the same number for those 2 which is not good. So I tried with the UUID method. To do so, I put a extra field in my model for the UUID which I generate in my controller at submission. Now I have a problem, how can I get the value of the UUID field to use it in the upload_to value of the FileField ?
Here is my Model : class Analysis(models.Model): uuidDir = models.CharField(max_length = 36) dirFile = 'documents/%Y/%m/%d/' + str(uuidDir) #?? structureFile = models.FileField(upload_to = dirFile) aliphFile = models.FileField(upload_to = dirFile) vdwFile = models.FileField(upload_to = dirFile) distGlyc = models.FloatField() defaultType = models.CharField(max_length = 8) outputName = models.CharField(max_length = 10) Is there a method that I can call on my uuidDir field to get his value or am I thinking completely wrong on this ? Thanks in advance for any help ! Amélie. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/35d55355-24e8-4a5b-bfe5-d6aa6fd6bf30%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.