Django logo (Photo credit: Wikipedia) |
originalTextFile = models.FileField(upload_to='documents/%Y/%m/%d') # original text if it was submitted as a fileIf you forget the upload_to attribute you will have the following error:
./manage.py syncdb Error: One or more models did not validate: textModif.texttask: "originalTextFile": FileFields require an "upload_to" attribute.To solve this error, you need to define the following elements in the settings.py Django configuration file:
MEDIA_ROOT = '/path/to/myproject/media/' MEDIA_URL = '/media/'With all these parameters correctly positioned, Django will store files to "media/documents/2012/11/24/" based on the current date and the content of the MEDIA_ROOT variable.
Acknowledgment: this post is largely inspired from the following page.
0 comments :
Post a Comment