views:

49

answers:

1

What is the preferred place to keep upload directory for a django project? I am pretty sure I shouldn't keep it inside the project for production, because then I have to always remember to move it between projects, if I upload a new version of my project. Where should I keep it then? (I am talking about a linux machine).

+4  A: 

I keep it in my site-media directory, along with CSS, images and JavaScript, like this:

site-media/
  img/
  css/
  js/
  uploads/

I then ignore the uploads directory in my version-control system, (you are using version control, right?).

Using this approach means your uploads can be served using whatever method you're using to serve your media (I serve it straight from Apache, using a symlink).

Dominic Rodger
+1 to this. `site-media` is a good choice. If you'd rather not put user uploaded files in `site-media` you can have another site level (as opposed to app specific) directory for storing the files.
Manoj Govindan
@Dominic: Mea culpa. Done :)
Manoj Govindan
By default, Django rises `SuspiciousOperation` exception if you try to save a file outside MEDIA_ROOT. See [this SO question](http://stackoverflow.com/questions/1729051/django-upload-to-outside-of-media-root/1729359#1729359) for example how to upload to other locations.
rebus