This is ok if I did not want to use the possibility to upload to a directory containing the the date... If you read the specs : http://docs.djangoproject.com/en/1.1/ref/models/fields/#filefield I can speciify that the upload path is formatted with : DEFAULT_UPLOAD_SUBFOLDER = 'upload/%Y/%m/%d'
This means that : "media.media_file" is in fact a reference to the file and not its path.... I will give it a try but I think I did & it was not OK \T, On Jan 9, 6:08 am, Sam Lai <samuel....@gmail.com> wrote: > If I have understood you correctly, the media_file attribute in your > model instances should hold the relative path to your file from > MEDIA_ROOT. To get the absolute path to the file, just use > os.path.join(settings.MEDIA_ROOT, media.media_file). > > 2010/1/9tsmets<tsm...@gmail.com>: > > > Dear, > > I have a Class that allows to upload Media Files > > > DEFAULT_UPLOAD_SUBFOLDER = 'upload/%Y/%m/%d' > > # For the time being, the value is set to a real absolute max 200 Gb > > ABSOLUTE_MAX_SIZE = 200 * 1024 * 1000 * 1024 * 1024 > > > class Media(models.Model): > > """ Model for any file (image, pdf, MS-document) """ > > media_file = models.FileField(upload_to=DEFAULT_UPLOAD_SUBFOLDER, > > max_length=ABSOLUTE_MAX_SIZE) > > ... > > > When posting a file via the Form : > > class MediaForm(forms.ModelForm): > > > class Meta: > > model = Media > > ... > > > Every thing goes fine but for the fact that I don't know the exact > > file name. > > >tsm...@calvin:~/Documents/python/gramps/trunk/src/web/upload/ > > 2010/01/08$ ls -la > > total 20 > > drwxr-xr-x 2tsmetstsmets4096 2010-01-09 02:07 . > > drwxr-xr-x 3tsmetstsmets4096 2010-01-08 14:53 .. > > -rwxr-xr-x 1tsmetstsmets 856 2010-01-09 02:07 Test_1__.pdf > > -rwxr-xr-x 1tsmetstsmets 856 2010-01-08 14:55 Test_1_.pdf > > -rwxr-xr-x 1tsmetstsmets 856 2010-01-08 14:53 Test_1.pdf > > > I however want to process that file and upon correct processing move > > it to another folder. > > Due to the fact that the folder is named : 'upload/%Y/%m/%d', I would > > not like to reconstruct the folder directory name myself. > > > Can someone help .. ? > > > \T, > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en.
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.