Search code examples
djangofilefield

Read data of Django FileField


I am trying to save/download the data on local directory before save it to database, which is selected in Django FileField. After download how do I maintain the instance of that selected file in that FileField so that I can save it to database?


Solution

  • Not sure if i completely understand your problem, but ...

    by default Django's FileField doesn't store the file in your database but on disk (though it can be done using a custom storage backend: http://djangosnippets.org/snippets/1305/). Only the reference to the file is stored in the database (See: http://docs.djangoproject.com/en/dev/topics/files/#file-storage).

    If you want to customize this behavior you should take a look at at docs: http://docs.djangoproject.com/en/dev/topics/http/file-uploads/#file-uploads