If you are using the django development server whilst developing then you can use django.views.static.serve to download static or media files. You should not use this method in production however as it is not considered stable. Just place this in your url.py file:
from settings import DEBUG, STATIC_DOC_ROOT, MEDIA_ROOT if DEBUG: urlpatterns += patterns('', (r'^.*/?static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': STATIC_DOC_ROOT}), (r'^site_media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': MEDIA_ROOT}) ) Then you can access static files from /static/path/to/file and you can access your uploaded media using /site_media/path/to/file You can of course use settings variables for the URL's as well as the roots but that's upto you. Not sure why files aren't being put into the /user_files/ directory that you have specified, they should be! On Jul 30, 11:38 am, Salvatore Leone <salvatore.le...@isti.cnr.it> wrote: > Hi again, > > I have configured MEDIA_ROOT = > '/home/testpec/public_html/pecwizard/uploads/' and the file uploads > works fine, so in the 'uploads' directory there are all my uploaded files. > > Two questions: > > 1. > in models.py I have the following: > > class Attach(models.Model): > attached_file = models.FileField(upload_to='user_files') > # other stuff > > why all of the files are stored in 'uploads' and not in > 'uploads/user_files/'? > > 2. > I can't download the files, probably I don't understand the MEDIA_URL > parameter. Here it is: > MEDIA_URL = 'http://localhost:8000/wiz/uploads/' > > but trying to access the files returns me a 404 error. > > I can workaround this configuring urls.py for serving static files. Is > this the right way to do it?? > > regards, > Salvatore --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---