Search code examples
djangodjango-modelsstatic-files

Uploading files with an ImageField and saving them to a static location


I have a problem with my app here. My configuration is as such I can upload a new release and symbolically link it for production -- however, this means every time I upload a new release, all of the photos that were uploaded in any parts of my entire project are wrapped into the old release and disappear.

How can I save these files to a static file location which does not get wrapped in the release? Thanks in advance.


Solution

  • I guess best for this is keeping your media files out of your source project folder, you could eg have a structure like:

    myproject
    |
    |----media
    |----src
    

    There's no need to have the media folder in the same directory as your source code, apps etc. So you have a solution where the dir with your release only contains static files! The same applies to the database, if you are using sqlite... Have a look at this for a more detailled structure!

    Of course this no must, but experience shows it makes live much easier!