> I've got an unusual situation with an app, and I'm wondering if anyone
> could make a suggestion.  The app will have a number of file upload
> fields for uploading files that are _not_ supposed to be made
> available to the webserver (as they are private).  I'd like for
> particular FileFields to be able to upload to somewhere that is not a
> subdirectory of MEDIA_ROOT. I made it work by:
1) Create two separate media directories: /media/public and
/media/restricted
2) Configure Apache to serve /media/public directory directly
3) Configure Apache to serve the /media/restricted directory using
mod_python
4) Set a url entry in urls.py to e.g.:

(r'^media/restricted/(?P<path>.*)','myproject.myapp.views.view_restricted_media')
5) Create view_restricted_media as:
     @restrict_to_superuser
     def view_restricted_media(request,path):
         return static.serve(request,path,RESTRICTED_MEDIA_DIR)
6) If you want to be able to set files from unrestricted to restricted
or the other way around, create a function to move the file from the
public media subdir to the restricted one and vice-versa.

The advantage of this approach is that you can restrict the media files
to whatever you may need, and the media files will still be available
in the admin interface.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to