Serving static file on Windows

514 views
Skip to first unread message

Alagu Madhu

unread,
May 24, 2011, 4:22:42 AM5/24/11
to Django users
Hi,


sample/
media/
js/jquery.1.6.1.min.js
css/
static/
js/jquery.1.6.1.min.js
css/



settings.py

import os
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media/')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static/')
STATIC_URL = '/static/'


urls.py


urlpatterns = patterns('',
(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.STATIC_ROOT}),






http://192.168.1.141:44/static/js/jquery.1.6.1.min.js



Page not found (404)
'js\jquery.1.6.1.min.js' could not be found



Thanks

Madhu


shofty

unread,
May 24, 2011, 2:42:12 PM5/24/11
to Django users
I thought we were still on jquery 1.5.1?

Matt

shofty

unread,
May 24, 2011, 2:44:19 PM5/24/11
to Django users
ignore that last comment, im clearly behind a version!

not sure why you're needing to static.serve the static files, if
you're on django 1.3 it does that bit for you.


On May 24, 9:22 am, Alagu Madhu <alma...@gmail.com> wrote:

Alagu Madhu

unread,
May 30, 2011, 5:19:15 AM5/30/11
to Django users
Hi,

sample/
static/
js/jquery.1.6.1.min.js
css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = '/static/'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
)

urls.py

urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
)

http://192.168.1.141:44/static/js/jquery.1.6.1.min.js

Page not found (404)
'js\jquery.1.6.1.min.js' could not be found


Thanks

Madhu




On May 24, 9:44 pm, shofty <m...@shofty.me> wrote:
> ignore that last comment, im clearly behind a version!
>
> not sure why you're needing to static.serve the static files, if
> you're on django 1.3 it does that bit for you.
>

Praveen Krishna R

unread,
May 30, 2011, 5:28:06 AM5/30/11
to django...@googlegroups.com
could you dump your urls.py ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
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.




--
Thanks and Regards,
Praveen Krishna R

Alagu Madhu

unread,
May 30, 2011, 6:57:46 AM5/30/11
to Django users
urls.py

from django.conf.urls.defaults import patterns, include, url


urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
)






On May 30, 12:28 pm, Praveen Krishna R <rpraveenkris...@gmail.com>
wrote:
> *could you dump your urls.py ?
> *
> *Praveen Krishna R*

Praveen Krishna R

unread,
May 31, 2011, 2:44:23 AM5/31/11
to django...@googlegroups.com
Pasting one of my earlier replies to the same question

Please check django official docs to find out how static files are served on production and development server.

in the dev server include a similiar snippet into your projects urls.py, urlpatterns:

(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',{'document_root': 'D:/djangoprojects/praveensprofile/templates/static'}),

and in the templates something similar to the below text.
<link href="/site_media/default.css" rel="stylesheet" type="text/css" />

Thanks and Regards,
Praveen Krishna R

Alagu Madhu

unread,
May 31, 2011, 5:50:38 AM5/31/11
to Django users
Hi,


I use Django 1.3.



sample/
static/
js/jquery.1.6.1.min.js
css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = 'http://192.168.1.141:44/static/'
TEMPLATE_DIRS = (
os.path.join(APP_DIR, 'templates/')
)

urls.py


from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
)



The above settings works.


Thanks

Madhu













On May 31, 9:44 am, Praveen Krishna R <rpraveenkris...@gmail.com>
wrote:
> *Pasting one of my earlier replies to the same question*
> ***
> *
> *Please check django official docs to find out how static files are served
> on production and development server.
>
> in the dev server include a similiar snippet into your projects
> urls.py, urlpatterns:
>
> (r'^site_media/(?P<path>.*)$', 'django.views.static.serve',{'document_root':
> 'D:/djangoprojects/praveensprofile/templates/static'}),
>
> and in the templates something similar to the below text.
> <link href="/site_media/default.css" rel="stylesheet" type="text/css" />
>
> *Praveen Krishna R*

Alagu Madhu

unread,
May 31, 2011, 6:28:59 AM5/31/11
to Django users
Hi,

I use Django 1.3.

sample/
static/
js/jquery.1.6.1.min.js
css/

settings.py

APP_DIR = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = os.path.join(APP_DIR, 'static/')
STATIC_URL = 'http://192.168.1.141:44/static/'
TEMPLATE_DIRS = (
os.path.join(APP_DIR, 'templates/')
)

urls.py

from django.conf.urls.defaults import patterns, include, url

urlpatterns = patterns('',
(r'^$', 'hydra.views.index'),
(r'^static/(?P<path>.*)$', 'django.views.static.serve',
{'document_root':'/django/spl/kk/static'}),
Reply all
Reply to author
Forward
0 new messages