Can't locate 'media' directory

88 views
Skip to first unread message

django-user59

unread,
May 15, 2012, 10:41:12 PM5/15/12
to django...@googlegroups.com
Hi,

I attempted to add 'media' directory to the root of my project and placed a css file and some ajax javascript. The server runtime is unable to locate it. Can someone help?

I have the following in settings.py

MEDIA_ROOT = os.path.join(ROOT_PATH, 'media')

The console error I get is:

C:\dev\Projects\ajax_tut\ajax_tut>python ../manage.py runserver
Validating models...
0 errors found
Django version 1.4, using settings 'ajax_tut.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[15/May/2012 19:11:12] "GET / HTTP/1.1" 200 613
[15/May/2012 19:11:12] "GET /media/style.css HTTP/1.1" 404 2312
[15/May/2012 19:11:12] "GET /media/jquery-1.2.6.min.js HTTP/1.1" 404 2342
[15/May/2012 19:11:28] "GET / HTTP/1.1" 200 613
[15/May/2012 19:11:28] "GET /media/style.css HTTP/1.1" 404 2312
[15/May/2012 19:11:28] "GET /media/jquery-1.2.6.min.js HTTP/1.1" 404 2342

Where do I place this directory and what do I set in settings.py and which directory do I launch the server? Once again, any help would be much appreciated.

Thanks,


Min Hong Tan

unread,
May 16, 2012, 6:55:09 PM5/16/12
to django...@googlegroups.com
hi,

your media folder location should be 

<ROOT_PATH>/media   

example: your  ROOT_PATH  is c:\project\ajax_tut
then your media file should be 

c:\project\ajax_tut\media

MEDIA_ROOT = os.path.join(ROOT_PATH, 'media')
MEDIA_URL = '/media/'     <---- like this should be ok.

you may try. hope it helps.

Regards,
MH



--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/XyZWqGOd6KoJ.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Venkat Rangan

unread,
May 17, 2012, 2:31:37 AM5/17/12
to django...@googlegroups.com
No, this did not work. Is there a way to print what the ROOT_PATH is, on an HTML page?

Min Hong Tan

unread,
May 17, 2012, 7:29:33 PM5/17/12
to django...@googlegroups.com
hi,

you may try this way.
in your settings.py

import os
ROOT_PATH  =  'c:/project/ajax_tut'   # take note. need to use black slash.
Reply all
Reply to author
Forward
0 new messages