0

Is it possible to upload a file in django using django's model.FileField() to a location that's not relative to /media ?. In my case upload an .html file to myproject/templates.

Paulo
  • 6,982
  • 7
  • 42
  • 56

2 Answers2

1

You cannot if I remember right, this kind of operation is in-secure. The file storage backend would warn it.
You could either customize the storage backend, or upload to directory like /media/user_template and set it in TEMPLATE_DIRS.

If you only want to use dynamic templates, check django-dbtemplates as a DB-based solution.

okm
  • 23,575
  • 5
  • 83
  • 90
0

try: models.FileField(upload_to = '...')

  • the value of upload_to gets appended to MEDIA_URL. So if i set upload_to='templates/' the actual path to this would me /media/templates. – Paulo Jun 27 '12 at 04:38