Paulo
Paulo

Reputation: 7342

django upload file to custom location

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.

Upvotes: 0

Views: 418

Answers (2)

okm
okm

Reputation: 23871

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.

Upvotes: 1

user809487
user809487

Reputation:

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

Upvotes: 0

Related Questions