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 syncdbTo solve this error, you need to define the following elements in the settings.py Django configuration file:
Error: One or more models did not validate:
textModif.texttask: "originalTextFile": FileFields require an "upload_to" attribute.
MEDIA_ROOT = '/path/to/myproject/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.
MEDIA_URL = '/media/'
Acknowledgment: this post is largely inspired from the following page.
No comments:
Post a Comment