UUID for unique directory name
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.
Re: UUID for unique directory name
Thanks for this, I was sure there were something to get access to the value of a field ! On Monday, August 25, 2014 4:00:23 PM UTC+2, Collin Anderson wrote: > > Roughly something like this: > > def dir_file(analysis, file_name): # should live outside your model > return '%s/%s' % (analysis.uuidDir, file_name) > > then models.FileField(upload_to=dir_file) > > -- 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/68a854ff-771e-4b03-9236-0c7da1b5616f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Is Django the best for my web app ?
Hello everyone, I have to do a web application at my work. I use to program with Python every day but never for web application. So I wanted to know if Django is the best choice for my problem. Here it is, in my application there will be only one form (with some file uploading). After the submission, I want to execute an internal Python script on those files on our servers. It seems pretty simple but I have no idea how to do this so do you think that Django will be able to do this quickly and safely ? Do you have examples of that kind of code ? Thanks in advance for your answers and sorry for possibly english mistakes :D 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/5790afb2-4890-48fd-8e42-8848ba20e691%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Is Django the best for my web app ?
Ok thanks for your answers. Yeah maybe that best suits not here, I meant is Django able to do what I plan to do before I start studying the framework and loss time. Let's see the tutorial then ! On Thursday, May 15, 2014 11:33:05 AM UTC+2, Amelie Bacle wrote: > > Hello everyone, > > I have to do a web application at my work. I use to program with Python > every day but never for web application. So I wanted to know if Django is > the best choice for my problem. Here it is, in my application there will be > only one form (with some file uploading). After the submission, I want to > execute an internal Python script on those files on our servers. > It seems pretty simple but I have no idea how to do this so do you think > that Django will be able to do this quickly and safely ? Do you have > examples of that kind of code ? > > Thanks in advance for your answers and sorry for possibly english mistakes > :D > > 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/ef7ce260-325d-4de1-8d44-3b4f8f51eea6%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: Is Django the best for my web app ?
Thanks again, I can see that the community of Django is very helpful now :). So if I understood well, I can just do a regular js script with AJAX that will execute a bash command on my python script ? I read that it may be dangerous, is that right ? And what about Python CGI ? Sorry if I ask basics questions, I feel a little bit lost on that subject... :( On Friday, May 16, 2014 10:19:11 AM UTC+2, Venkatraman.S. wrote: > Honestly, django may be an overkill for you, as something lightweight like > Flask might do the magic for this particular usecase. Or even a simple > html with js should do without any added framework shebang. > > BUT, django, comes with an awesome community and loads of packages that > might help you a tonne when you want to grow your application or want to > create/add more products/features. > > On Thu, May 15, 2014 at 6:43 PM, Amelie Bacle > > > wrote: > >> Ok thanks for your answers. Yeah maybe that best suits not here, I meant >> is Django able to do what I plan to do before I start studying the >> framework and loss time. Let's see the tutorial then ! >> >> On Thursday, May 15, 2014 11:33:05 AM UTC+2, Amelie Bacle wrote: >>> >>> Hello everyone, >>> >>> I have to do a web application at my work. I use to program with Python >>> every day but never for web application. So I wanted to know if Django is >>> the best choice for my problem. Here it is, in my application there will be >>> only one form (with some file uploading). After the submission, I want to >>> execute an internal Python script on those files on our servers. >>> It seems pretty simple but I have no idea how to do this so do you think >>> that Django will be able to do this quickly and safely ? Do you have >>> examples of that kind of code ? >>> >>> Thanks in advance for your answers and sorry for possibly english >>> mistakes :D >>> >>> 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...@googlegroups.com . >> To post to this group, send email to django...@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/ef7ce260-325d-4de1-8d44-3b4f8f51eea6%40googlegroups.com<https://groups.google.com/d/msgid/django-users/ef7ce260-325d-4de1-8d44-3b4f8f51eea6%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/dc1fe1bf-00c1-42bf-aab7-2c169683ac07%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.