Bug? django fails to serve static files in Windows 10

2019-10-02 Thread red sky
my system: Windows 10 1903, Python 3.7.4, 64 bit

My directory structure

%USERPROFILE%/Desktop/myproject/manage.py
%USERPROFILE%/Desktop/myproject/some_app/(...)
%USERPROFILE%/Desktop/myproject/myproject/sqlite3.db
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/media (...)
%USERPROFILE%/Desktop/myproject/myproject/settings (with files __init__.py, 
settings_base.py, settings_devel.py, settings_production.py)
%USERPROFILE%/Desktop/myproject/myproject/static (...)
%USERPROFILE%/Desktop/myproject/myproject/static/css/styles.css
%USERPROFILE%/Desktop/myproject/myproject/more_apps/(...)

My urls.py (relevant parts)

from .settings import ENVIRONMENT, MEDIA_URL, MEDIA_ROOT, STATIC_URL, 
STATIC_ROOT
(...)
if ENVIRONMENT=="development":
import debug_toolbar
urlpatterns += [path('__debug__/',include (debug_toolbar.urls))]
urlpatterns += static(MEDIA_URL,document_root=MEDIA_ROOT)
urlpatterns += static(STATIC_URL,document_root=STATIC_ROOT)
urlpatterns += router.urls


My settings_base.py (relevant part)

INSTALLED_APPS = [...
'django.contrib.staticfiles',
...]

MEDIA_ROOT = BASE_DIR + '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
STATIFCILES_DIRS = ["","//",STATIC_ROOT,
"C://Users//alfre//Desktop//memes//memes//"]
MEDIA_URL='/media/'

My settings_base.py (relevant part)

MEDIA_ROOT = BASE_DIR + '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR , 'static')
#STATIFCILES_DIRS = ["","//",STATIC_ROOT,
"C://Users//alfre//Desktop//memes//memes//"]
MEDIA_URL='/media/'

(The error happens with several variants of the STATICFILES_DIRS, even with 
that line disabled or with several combinations)

The template shows the adress right, so I guess that is not the problem. 
Furthermore, the issue also happens when I request the file manually 
(http://127.0.0.1:8000/static/css/styles.css).

The error is "GET /static/css/styles.css HTTP/1.1" 404 1767
 
Strangely enough, I have not had any error with MEDIA images (served by 
sorl_thumbnails).

Strange behaviour:

If I replace STATIC_URL = '/static/' with 'static/' my static files are 
SOMETIMES served (but only when requested from root) (it seems I have to 
start the server, request the page, change form /static/ to static/ and 
then request it again to have the css served!), but django toolbar static 
files are not (they give back a 404 error , but they complain about the 
path GET /myproject/static/debug_toolbar/styles.css HTTP/1.1" 404 1767

As you can expect, this issue is relevant for development, given the 
importance of stylesheets.

Finally, if I insert print(STATIC_ROOT) in my settings files, I get the 
correct directory displayed on the console. But the files are still not 
delivered.

Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9043ccd-c93a-4f17-a8a8-9f72314ca740%40googlegroups.com.


Re: serve static files

2013-08-26 Thread Wesley Ni
Yeah, correct!
Add nostatic option to runserver fix my problem.
Thanks.

在 2013年8月27日星期二UTC-4上午12时46分08秒,Jani Tiainen写道:
>
> If you're using contrib.staticfiles app, your DEBUG is True and you're 
> using runserver django automagically maps (overrides) your staticfile 
> serving. 
>
> If you want to manually add staticfile serving, you have to give 
> --nostatic parameter to runserver to omit all magic that happena 
> automatically. 
>
>
> On Mon, 26 Aug 2013 07:58:38 -0700 (PDT) 
> Wesley Ni > wrote: 
>
> > I hit an issue when trying serve static files. 
> > 
> > In settings, debug is True, and with the followinig: 
> > STATIC_ROOT = os.path.join(freelancer_path,"staticfiles") 
> > STATIC_URL = '/staticfiles/' 
> > 
> > urls.py: 
> > (r'^staticfiles/(?P.*)$','django.contrib.staticfiles.views.serve', 
> > {'document_root' : STATIC_ROOT,'show_indexes' : True}), 
> > 
> > Problem is, when accessing http://127.0.0.1:8000/staticfiles/, I got 
> this: 
> > Page not found (404) 
> > Request Method: GET 
> > Request URL: http://127.0.0.1:8000/staticfiles/ 
> > 
> > Why? I thought I would get folder indexes because I set show_indexes to 
> > True. 
> > 
> > And, later, I find that, if I set the url pattern prefix not same to 
> > STATIC_URL, 
> > say, maybe : 
> > (r'^files/(?P.*)$','django.contrib.staticfiles.views.serve', 
> > {'document_root' : STATIC_ROOT,'show_indexes' : True}), 
> > And, then, http://127.0.0.1:8000/files/ is OK to show folder lists. 
> > 
> > Could anyone help explain and fix? 
> > 
> > Thanks. 
> > Wesley 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
> -- 
>
> Jani Tiainen 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: serve static files

2013-08-26 Thread Jani Tiainen
If you're using contrib.staticfiles app, your DEBUG is True and you're using 
runserver django automagically maps (overrides) your staticfile serving.

If you want to manually add staticfile serving, you have to give --nostatic 
parameter to runserver to omit all magic that happena automatically.


On Mon, 26 Aug 2013 07:58:38 -0700 (PDT)
Wesley Ni  wrote:

> I hit an issue when trying serve static files.
> 
> In settings, debug is True, and with the followinig:
> STATIC_ROOT = os.path.join(freelancer_path,"staticfiles")
> STATIC_URL = '/staticfiles/'
> 
> urls.py:
> (r'^staticfiles/(?P.*)$','django.contrib.staticfiles.views.serve',
> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
> 
> Problem is, when accessing http://127.0.0.1:8000/staticfiles/, I got this:
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/staticfiles/
> 
> Why? I thought I would get folder indexes because I set show_indexes to 
> True.
> 
> And, later, I find that, if I set the url pattern prefix not same to 
> STATIC_URL, 
> say, maybe :
> (r'^files/(?P.*)$','django.contrib.staticfiles.views.serve',
> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
> And, then, http://127.0.0.1:8000/files/ is OK to show folder lists.
> 
> Could anyone help explain and fix?
> 
> Thanks.
> Wesley
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 

Jani Tiainen

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: serve static files

2013-08-26 Thread Wesley Ni
Sorry but it still doesn't work.

http://stackoverflow.com/questions/4730716/django-static-files-problem Here 
also mentioned the issue that pattern conflicts with STATIC_URL.

在 2013年8月26日星期一UTC-4下午1时28分42秒,mantaszilinskis写道:
>
> import settings
> instead of 'document_root' : STATIC_ROOT, try 'document_root' : 
> settings.STATIC_ROOT,
>
>
> On Mon, Aug 26, 2013 at 10:05 AM, Wesley Ni 
> > wrote:
>
>> Forget to say that I use Django 1.5.2
>>
>> 在 2013年8月26日星期一UTC-4上午10时58分38秒,Wesley Ni写道:
>>
>>> I hit an issue when trying serve static files.
>>>
>>> In settings, debug is True, and with the followinig:
>>> STATIC_ROOT = os.path.join(freelancer_path,"**staticfiles")
>>> STATIC_URL = '/staticfiles/'
>>>
>>> urls.py:
>>> (r'^staticfiles/(?P.*)$'**,'django.contrib.staticfiles.**
>>> views.serve',
>>> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
>>>
>>> Problem is, when accessing 
>>> http://127.0.0.1:8000/**staticfiles/<http://127.0.0.1:8000/staticfiles/>, 
>>> I got this:
>>> Page not found (404)
>>> Request Method: GET
>>> Request URL: 
>>> http://127.0.0.1:8000/**staticfiles/<http://127.0.0.1:8000/staticfiles/>
>>>
>>> Why? I thought I would get folder indexes because I set show_indexes to 
>>> True.
>>>
>>> And, later, I find that, if I set the url pattern prefix not same to 
>>> STATIC_URL, 
>>> say, maybe :
>>> (r'^files/(?P.*)$','**django.contrib.staticfiles.**views.serve',
>>> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
>>> And, then, http://127.0.0.1:8000/files/ is OK to show folder lists.
>>>
>>> Could anyone help explain and fix?
>>>
>>> Thanks.
>>> Wesley
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: serve static files

2013-08-26 Thread Mantas Zilinskis
import settings
instead of 'document_root' : STATIC_ROOT, try 'document_root' :
settings.STATIC_ROOT,


On Mon, Aug 26, 2013 at 10:05 AM, Wesley Ni  wrote:

> Forget to say that I use Django 1.5.2
>
> 在 2013年8月26日星期一UTC-4上午10时58分38秒,Wesley Ni写道:
>
>> I hit an issue when trying serve static files.
>>
>> In settings, debug is True, and with the followinig:
>> STATIC_ROOT = os.path.join(freelancer_path,"**staticfiles")
>> STATIC_URL = '/staticfiles/'
>>
>> urls.py:
>> (r'^staticfiles/(?P.*)$'**,'django.contrib.staticfiles.**
>> views.serve',
>> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
>>
>> Problem is, when accessing 
>> http://127.0.0.1:8000/**staticfiles/<http://127.0.0.1:8000/staticfiles/>,
>> I got this:
>> Page not found (404)
>> Request Method: GET
>> Request URL: 
>> http://127.0.0.1:8000/**staticfiles/<http://127.0.0.1:8000/staticfiles/>
>>
>> Why? I thought I would get folder indexes because I set show_indexes to
>> True.
>>
>> And, later, I find that, if I set the url pattern prefix not same to
>> STATIC_URL,
>> say, maybe :
>> (r'^files/(?P.*)$','**django.contrib.staticfiles.**views.serve',
>> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
>> And, then, http://127.0.0.1:8000/files/ is OK to show folder lists.
>>
>> Could anyone help explain and fix?
>>
>> Thanks.
>> Wesley
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


serve static files

2013-08-26 Thread Wesley Ni
I hit an issue when trying serve static files.

In settings, debug is True, and with the followinig:
STATIC_ROOT = os.path.join(freelancer_path,"staticfiles")
STATIC_URL = '/staticfiles/'

urls.py:
(r'^staticfiles/(?P.*)$','django.contrib.staticfiles.views.serve',
{'document_root' : STATIC_ROOT,'show_indexes' : True}),

Problem is, when accessing http://127.0.0.1:8000/staticfiles/, I got this:
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/staticfiles/

Why? I thought I would get folder indexes because I set show_indexes to 
True.

And, later, I find that, if I set the url pattern prefix not same to 
STATIC_URL, 
say, maybe :
(r'^files/(?P.*)$','django.contrib.staticfiles.views.serve',
{'document_root' : STATIC_ROOT,'show_indexes' : True}),
And, then, http://127.0.0.1:8000/files/ is OK to show folder lists.

Could anyone help explain and fix?

Thanks.
Wesley

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: serve static files

2013-08-26 Thread Wesley Ni
Forget to say that I use Django 1.5.2

在 2013年8月26日星期一UTC-4上午10时58分38秒,Wesley Ni写道:
>
> I hit an issue when trying serve static files.
>
> In settings, debug is True, and with the followinig:
> STATIC_ROOT = os.path.join(freelancer_path,"staticfiles")
> STATIC_URL = '/staticfiles/'
>
> urls.py:
> (r'^staticfiles/(?P.*)$','django.contrib.staticfiles.views.serve',
> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
>
> Problem is, when accessing http://127.0.0.1:8000/staticfiles/, I got this:
> Page not found (404)
> Request Method: GET
> Request URL: http://127.0.0.1:8000/staticfiles/
>
> Why? I thought I would get folder indexes because I set show_indexes to 
> True.
>
> And, later, I find that, if I set the url pattern prefix not same to 
> STATIC_URL, 
> say, maybe :
> (r'^files/(?P.*)$','django.contrib.staticfiles.views.serve',
> {'document_root' : STATIC_ROOT,'show_indexes' : True}),
> And, then, http://127.0.0.1:8000/files/ is OK to show folder lists.
>
> Could anyone help explain and fix?
>
> Thanks.
> Wesley
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-22 Thread Nikolas Stevenson-Molnar
Try changing the first line to {% load static from staticfiles %}

_Nik

On 8/21/2013 6:27 PM, Ideo Rex wrote:
> {% load staticfiles %}
>
> 
>
> This is just for my css file (there are other categories under lifestream.
>
> server: https://my.site.com/DJStatic/static/livestream/css/style.css
>
> On Wednesday, August 21, 2013 6:18:37 PM UTC-7, Nikolas
> Stevenson-Molnar wrote:
>
> That should work... how are you referencing your static files from
> your
> templates?
>
> _Nik
>
> On 8/21/2013 6:09 PM, Ideo Rex wrote:
> > Hello,
> > I have a different request that I couldn't find anywhere else on
> the
> > internet. I'm an intern who has built a Django Web Application
> for my
> > project (basically a large experiment). The cite will never leave
> > development, but I'm holding my static files and templates on
> another
> > server. I want Django to look for static files on this website.
> >
> > Currently my project is 'livestream', in livestream there are
> two sub
> > directories: 'templates' & 'static'
> > On my server I have https://my.site.com/DJStatic/ - inside of
> DJStatic
> > are two sub directories: 'templates' & 'static'
> >
> > How do I tell django to look in the server for the static files
> rather
> > than the local directory?
> >
> >
> > Tests:
> > I have removed the local static files and set STATIC_URL :
> > https://my.site.com/DJStatic/static/
> , but it doesn't work this way.
> > Any Ideas on how to fix this?
> >
> > Thanks
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Django users" group.
> > To unsubscribe from this group and stop receiving emails from
> it, send
> > an email to django-users...@googlegroups.com .
> > To post to this group, send email to django...@googlegroups.com
> .
> > Visit this group at http://groups.google.com/group/django-users
> .
> > For more options, visit https://groups.google.com/groups/opt_out
> .
>
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Kelvin Wong
This is how I do it.

In settings.py:

STATIC_ROOT = '/home/user/app/site_media/static/'  # Generated files here 
from 'manage.py collectstatic'

STATIC_URL = 'http://static.example.com/static/'

In templates:

{% load staticfiles %}

...



Produces:

http://static.example.com/static/myapp/stylesheets/app.css"; 
rel="stylesheet" type="text/css">

If static.example.com is behind Nginx this is in your static server conf 
file:

# Nginx staticfiles setting

location /site_media/ {
  alias /home/user/app/site_media/;
}

This is a made up example, but the real thing is close to it.

K

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Ideo Rex
{% load staticfiles %}



This is just for my css file (there are other categories under lifestream.

server: https://my.site.com/DJStatic/static/livestream/css/style.css

On Wednesday, August 21, 2013 6:18:37 PM UTC-7, Nikolas Stevenson-Molnar 
wrote:
>
> That should work... how are you referencing your static files from your 
> templates? 
>
> _Nik 
>
> On 8/21/2013 6:09 PM, Ideo Rex wrote: 
> > Hello, 
> > I have a different request that I couldn't find anywhere else on the 
> > internet. I'm an intern who has built a Django Web Application for my 
> > project (basically a large experiment). The cite will never leave 
> > development, but I'm holding my static files and templates on another 
> > server. I want Django to look for static files on this website. 
> > 
> > Currently my project is 'livestream', in livestream there are two sub 
> > directories: 'templates' & 'static' 
> > On my server I have https://my.site.com/DJStatic/ - inside of DJStatic 
> > are two sub directories: 'templates' & 'static' 
> > 
> > How do I tell django to look in the server for the static files rather 
> > than the local directory? 
> > 
> > 
> > Tests: 
> > I have removed the local static files and set STATIC_URL : 
> > https://my.site.com/DJStatic/static/, but it doesn't work this way. 
> > Any Ideas on how to fix this? 
> > 
> > Thanks 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Django users" group. 
> > To unsubscribe from this group and stop receiving emails from it, send 
> > an email to django-users...@googlegroups.com . 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > Visit this group at http://groups.google.com/group/django-users. 
> > For more options, visit https://groups.google.com/groups/opt_out. 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Using an external Server to serve Static files - Development Server

2013-08-21 Thread Nikolas Stevenson-Molnar
That should work... how are you referencing your static files from your
templates?

_Nik

On 8/21/2013 6:09 PM, Ideo Rex wrote:
> Hello,
> I have a different request that I couldn't find anywhere else on the
> internet. I'm an intern who has built a Django Web Application for my
> project (basically a large experiment). The cite will never leave
> development, but I'm holding my static files and templates on another
> server. I want Django to look for static files on this website.
>
> Currently my project is 'livestream', in livestream there are two sub
> directories: 'templates' & 'static'
> On my server I have https://my.site.com/DJStatic/ - inside of DJStatic
> are two sub directories: 'templates' & 'static'
>
> How do I tell django to look in the server for the static files rather
> than the local directory?
>
>
> Tests:
> I have removed the local static files and set STATIC_URL :
> https://my.site.com/DJStatic/static/, but it doesn't work this way.
> Any Ideas on how to fix this?
>
> Thanks
> -- 
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Using an external Server to serve Static files - Development Server

2013-08-21 Thread Ideo Rex
Hello,
I have a different request that I couldn't find anywhere else on the 
internet. I'm an intern who has built a Django Web Application for my 
project (basically a large experiment). The cite will never leave 
development, but I'm holding my static files and templates on another 
server. I want Django to look for static files on this website.

Currently my project is 'livestream', in livestream there are two sub 
directories: 'templates' & 'static'
On my server I have https://my.site.com/DJStatic/ - inside of DJStatic are 
two sub directories: 'templates' & 'static'

How do I tell django to look in the server for the static files rather than 
the local directory?


Tests:
I have removed the local static files and set STATIC_URL : 
https://my.site.com/DJStatic/static/, but it doesn't work this way. Any 
Ideas on how to fix this?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Serve static files in production server

2013-01-02 Thread Stefano Tranquillini


On Sunday, December 30, 2012 6:01:24 PM UTC+1, Amirouche wrote:
>
> Héllo Stefano,
>
> On Sunday, December 30, 2012 1:27:12 PM UTC+1, Stefano Tranquillini wrote:
>>
>> Hi all.
>> in the appfog ML we were fighting again the possibility to serve static 
>> file in django without using an external server.
>> So far AF does not provide a setup of the server to split the server in 
>> static and dynamic (django) folders.
>> so, one of the solution is to use this
>>
>> # urls.py 
>> urlpatterns += patterns('', 
>> url(r'^static/(?P.*)$', 'django.views.static.serve', { 
>> 'document_root': settings.STATIC_ROOT}) 
>> )
>>
>> but, is it ok to use this trick in django or will it lead to problems 
>> (aka memory problems and stuff like that)?
>>
>
> The documentation state «Again, this view is *not* hardened for 
> production use» [1]
>
> What is the particular issue your are facing ? Maybe tproxy [2] can help.
>

the problem is that the appfog server does not provide a way to set up 
static part. so for convenience i (we) tried to use a workaround for 
solving the problem.

ciao
 

>
> Regards,
>
> Amirouche
>
> [1] 
> https://docs.djangoproject.com/en/dev/howto/static-files/#django.views.static.serve
> [2] https://github.com/benoitc/tproxy
>
>>

-- 
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/-/_Rh0njYy--UJ.
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.



Re: Serve static files in production server

2012-12-30 Thread Amirouche
Héllo Stefano,

On Sunday, December 30, 2012 1:27:12 PM UTC+1, Stefano Tranquillini wrote:
>
> Hi all.
> in the appfog ML we were fighting again the possibility to serve static 
> file in django without using an external server.
> So far AF does not provide a setup of the server to split the server in 
> static and dynamic (django) folders.
> so, one of the solution is to use this
>
> # urls.py 
> urlpatterns += patterns('', 
> url(r'^static/(?P.*)$', 'django.views.static.serve', { 
> 'document_root': settings.STATIC_ROOT}) 
> )
>
> but, is it ok to use this trick in django or will it lead to problems (aka 
> memory problems and stuff like that)?
>

The documentation state «Again, this view is *not* hardened for production 
use» [1]

What is the particular issue your are facing ? Maybe tproxy [2] can help.

Regards,

Amirouche

[1] 
https://docs.djangoproject.com/en/dev/howto/static-files/#django.views.static.serve
[2] https://github.com/benoitc/tproxy

>

-- 
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/-/WjCrTrhhcyEJ.
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.



Re: How to serve static files on heroku without any cloud storage like Amazon S3

2012-07-07 Thread Rafael Durán Castañeda

El 08/07/12 06:08, surya escribió:
My project is on heroku and my website templates has some CSS, JS 
files. Totally 5 of them.


I don't want to get off with amazon s3 for the sake of those 5 files 
(very small ones). However, I even need to enter my credit -card, 
which I don't like :P


So, as far as I know, my only option is to configure and run those 
static file on heroku. Can anyone tell me how to do that??


I searched a lot but couldn't find any site which clearly explains it.

PS: I am using gunicorn on heroku (I know nothing about it, went 
through some sites to configue).
First I had to learn Apache Httpd.. an now gunicorn (I think it takes 
some time)

--
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/-/CKssXd9FL_QJ.

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.

Try http://matthewphiong.com/managing-django-static-files-on-heroku

--
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.



How to serve static files on heroku without any cloud storage like Amazon S3

2012-07-07 Thread surya
My project is on heroku and my website templates has some CSS, JS files. 
Totally 5 of them.

I don't want to get off with amazon s3 for the sake of those 5 files (very 
small ones). However, I even need to enter my credit -card, which I don't 
like :P

So, as far as I know, my only option is to configure and run those static 
file on heroku. Can anyone tell me how to do that??

I searched a lot but couldn't find any site which clearly explains it.

PS: I am using gunicorn on heroku (I know nothing about it, went through 
some sites to configue).
First I had to learn Apache Httpd.. an now gunicorn (I think it takes some 
time)

-- 
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/-/CKssXd9FL_QJ.
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.



Re: How can I serve static files while requiring Django-based access permissions?

2011-11-09 Thread zak
Thanks for another great suggestion.

My really pressing questions have been successfully answered, I now
have a high-performance solution for the final version and a purely
Python/Django solution for initial testing and demos. Hopefully I can
figure out how to make the high-performance solution work, dealing
with Apache or Nginx is not nearly as fun as Python.

Background, for the curious: Tom's guess that I am making a pluggable
app is close; I am making an app that will be deployed in at least two
configurations (Windows and Linux) using probably two different HTTP
servers (Apache and undecided). I want it to work before I have fully
learned the ins and outs of each HTTP server on each OS, so I can use
django.views.static.serve for early testing and demos.

Zak

On Nov 9, 5:27 am, Tom Evans  wrote:
>
> In that case, just use django.views.static.serve:
>
> from django.views.static import serve
>
> def myview(request):
>   ...
>   return serve(request, document_root="/path/to/dir/holding/file"
> path="filename.doc")
>
> It is significantly slower than asking the web server to do it though
> - I assume you are doing this as this will be a pluggable app? If so,
> you should control this behaviour with a settings option, so that
> people can do it the optimal way if they want.
>
> Cheers
>
> Tom

-- 
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.



Re: How can I serve static files while requiring Django-based access permissions?

2011-11-09 Thread Tom Evans
On Tue, Nov 8, 2011 at 11:12 PM, zak  wrote:
> Thank you, that is a very helpful suggestion.
>
> However, I have a followup question. What are my options if:
>
> 1. It is okay to be slow (low performance), and
> 2. The method must work on any webserver, not necessarily or
> specifically Apache or Nginx.
>
> In pure Python/Django, how do I open a file on the hard disk and put
> it into an HttpResponse object? Is FileWrapper involved? How come I
> can't find any documentation on 'FileWrapper' by searching
> djangoproject.org?
>
> Thanks again,
>
> Zak
>

In that case, just use django.views.static.serve:

from django.views.static import serve

def myview(request):
  ...
  return serve(request, document_root="/path/to/dir/holding/file"
path="filename.doc")


It is significantly slower than asking the web server to do it though
- I assume you are doing this as this will be a pluggable app? If so,
you should control this behaviour with a settings option, so that
people can do it the optimal way if they want.

Cheers

Tom

-- 
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.



Re: How can I serve static files while requiring Django-based access permissions?

2011-11-08 Thread zak
Thank you, that is a very helpful suggestion.

However, I have a followup question. What are my options if:

1. It is okay to be slow (low performance), and
2. The method must work on any webserver, not necessarily or
specifically Apache or Nginx.

In pure Python/Django, how do I open a file on the hard disk and put
it into an HttpResponse object? Is FileWrapper involved? How come I
can't find any documentation on 'FileWrapper' by searching
djangoproject.org?

Thanks again,

Zak

On Nov 8, 5:25 pm, Ian Clelland  wrote:
> On Tue, Nov 8, 2011 at 2:11 PM, zak2011  wrote:
> > Dear Django Users,
>
> > tl;dr: Please tell me what strategies I might use to serve a large
> > static file from within Django, from views.py.
>
> > If I want to limit access to a particular page in a Django app, I can
> > do something like this in views.py:
>
> > (Note: I will use four periods to indent, because spaces or tabs might
> > not display properly.)
>
> > def private_page(request):
> > if special_permissions_checking_function(request.user):
> > return render_to_response('private_page_template.html')
> > else:
> > return render_to_response('access_denied.html')
>
> > What if I want to limit access to a large static file, instead of a
> > dynamically generated HTML template?
>
> The fastest way to do this is to tell the web server to serve the file from
> a protected location. Apache and nginx both have ways to signal from python
> code that a file should be read from disk and streamed to the user. This
> file doesn't have to be in a location which is accessible through a normal
> web request; ideally all access to it would be through your app, and you
> can do whatever access checks that you want to before serving it.
>
> Look up X-SENDFILE for Apache, or X-Accel-Redirect for nginx for the
> details.
>
> Ian
>
>
>
> > Ideally the resulting website will be fast, but I also want to hear
> > options that might be low performance.
>
> > Thank you,
>
> > Zak
>
> > --
> > 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.
>
> --
> Regards,
> Ian Clelland
> 

-- 
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.



Re: How can I serve static files while requiring Django-based access permissions?

2011-11-08 Thread Ian Clelland
On Tue, Nov 8, 2011 at 2:11 PM, zak2011  wrote:

> Dear Django Users,
>
> tl;dr: Please tell me what strategies I might use to serve a large
> static file from within Django, from views.py.
>
> If I want to limit access to a particular page in a Django app, I can
> do something like this in views.py:
>
> (Note: I will use four periods to indent, because spaces or tabs might
> not display properly.)
>
> def private_page(request):
> if special_permissions_checking_function(request.user):
> return render_to_response('private_page_template.html')
> else:
> return render_to_response('access_denied.html')
>
> What if I want to limit access to a large static file, instead of a
> dynamically generated HTML template?
>
>
The fastest way to do this is to tell the web server to serve the file from
a protected location. Apache and nginx both have ways to signal from python
code that a file should be read from disk and streamed to the user. This
file doesn't have to be in a location which is accessible through a normal
web request; ideally all access to it would be through your app, and you
can do whatever access checks that you want to before serving it.

Look up X-SENDFILE for Apache, or X-Accel-Redirect for nginx for the
details.

Ian


> Ideally the resulting website will be fast, but I also want to hear
> options that might be low performance.
>
> Thank you,
>
> Zak
>
> --
> 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.
>
>


-- 
Regards,
Ian Clelland


-- 
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.



How can I serve static files while requiring Django-based access permissions?

2011-11-08 Thread zak2011
Dear Django Users,

tl;dr: Please tell me what strategies I might use to serve a large
static file from within Django, from views.py.

If I want to limit access to a particular page in a Django app, I can
do something like this in views.py:

(Note: I will use four periods to indent, because spaces or tabs might
not display properly.)

def private_page(request):
if special_permissions_checking_function(request.user):
return render_to_response('private_page_template.html')
else:
return render_to_response('access_denied.html')

What if I want to limit access to a large static file, instead of a
dynamically generated HTML template?

Ideally the resulting website will be fast, but I also want to hear
options that might be low performance.

Thank you,

Zak

-- 
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.



Re: Cannot serve static files

2009-01-22 Thread john

Ok finally got it. David Zhou above, earlier mentioned adding static
file directory to css link (ie,  ) but when i did that it didn't work. I
must have had something wrong somewhere else. Anyway, i made some more
changes after reading info here:
http://stackoverflow.com/questions/446026/django-how-do-you-serve-media-stylesheets-and-link-to-them-within-templates

So given above directory structure i have this working now with the
following:
settings.py
MEDIA_ROOT = 'c:/dev/proj/app/media/' (i changed from 'c:\dev\proj\app
\media\' not sure if it mattered)
MEDIA_URL = '/media/'
ADMIN_MEDIA_PREFIX =  '/adminmedia/'
from what i gather, media and admin_media can't be the same directory

urls.py
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),

base.html template


What a effin hassle this has been. Django needs inprovement here.
Nothing wrong with building a recommended directory structure and/or
publishing better instructions on this. This type of thing is very
different for people coming from standard page style development. Dir
structure and url routing seem to be built into most MVC systems (at
least the ones i looked into before django).


On Jan 22, 12:32 pm, john  wrote:
> ah ok. good catch. My MEDIA_ROOT = C:\dev\proj. But my media directory
> is actually in my app directory, one directory down. I fixed
> MEDIA_ROOT to equal C:\dev\proj\app and still not having any luck. my
> use of -\ in directory structure example is just to indicate a folder
> in directory tree. Let me clarify:
>
> C:\dev\proj is project directory
> C:\dev\proj\app is application directory. Under this i have
> 'adminmedia', 'media' and 'templates' directories. So static files are
> here: C:\dev\proj\app\media.
> css file is here: C:\dev\proj\app\media\css\styles.css
> settings file is here: C:\dev\proj\settings.py
>
> like i said i now have MEDIA_ROOT set to C:\dev\proj\app, but still
> not working. In template i was told to use  type="text/css" href="{{MEDIA_URL}}css/styles.css">.
>
> MEDIA_URL not MEDIA_ROOT
>
> regardless, do i have to pass context for MEDIA_URL in view so
> template knows what it is?? is that the problem?
>
> Thanks for helping, btw. Much appreciated.
>
> On Jan 22, 11:57 am, Puneet Madaan  wrote:
>
> > well at my side it works well on both *nix and windoof platforms... here is
> > what I use on my projects...
>
> > settings.py
> > --
> > import platform
> > import os
>
> > PROJECT_DIR = os.path.dirname( os.path.abspath(__file__))
> > MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static')
> > ---
>
> > urls.py
> > -
> > from django.conf.urls.defaults import *
> > from django.contrib import admin
> > from django.conf import settings
>
> > urlpatterns = patterns('',
> >     #urls for your project
> >     (r'^static/(?P.*)$', 'django.views.static.serve',
> >         {'document_root': settings.MEDIA_ROOT}),
> > )
> > 
> > where i use a directory named 'static' residing in same folder, where i have
> > my settings.py   can you please place 'print MEDIA_ROOT' inside your
> > settings.py and check the terminal the path is spilts out ? because your '-'
> > convention before '-\media' is sort confusing, and its missing before
> > manage.py and settings.py  is media folder residing really in the same
> > directory where settings.py ?
>
> > c:\dev
>
> > >   -\proj
> > >      __init__.py
> > >      manage.py
> > >      settings.py
> > >      urls.py
> > >      -\app
> > >      -__init__.py
> > >      -admin.py
> > >      -models.py
> > >      -views.py
> > >      -\adminmedia
> > >      -\media
> > >        -\css
> > >          -styles.css
> > >        -\images
> > >      -\templates
> > >        -base.html
> > >        -index.html
>
> > if 'print MEDIA_ROOT' spilts out a path different from your media folder,
> > then you know where is the problem ..
>
> > Greetings,
> > Puneet
>
> > On Thu, Jan 22, 2009 at 5:40 PM, john  wrote:
>
> > > Thanks but no change.
>
> > > On Jan 22, 11:30 am, Puneet Madaan  wrote:
> > > > beside  > > href="{MEDIA_URL}css/styles.css">
> > > > you need to correct settings.py to
>
> > > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))
>
> > > > On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:
>
> > > > > Thanks but no change.
>
> > > > > On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> > > > > > change
> > > > > > 
> > > > > > to
> > > > > >  > > href="{MEDIA_URL}css/styles.css">
>
> > > > > > Dj Gilcrease
> > > > > > OpenRPG Developer
> > > > > > ~~http://www.openrpg.com
>
> > > > > > On Thu, Jan 22, 2009 at 8:53 AM, john 
> > > wrote:
>
> > > > > > > No matter what i do i can't get my css to load. 100% Frustrated
> > > with
> > > > > > > Django. My index page loads when i requesthttp://
> > > 127.0.0.1:8000/but
> > > > > > > it is not styled. Django dev server returns 404 in console for 
> > > > > > > "GET
> > > /
> > > > > > > css/styles.css HTTP/1.1"
>
> > > > > > > In my base template i have:

Re: Cannot serve static files

2009-01-22 Thread john

ah ok. good catch. My MEDIA_ROOT = C:\dev\proj. But my media directory
is actually in my app directory, one directory down. I fixed
MEDIA_ROOT to equal C:\dev\proj\app and still not having any luck. my
use of -\ in directory structure example is just to indicate a folder
in directory tree. Let me clarify:

C:\dev\proj is project directory
C:\dev\proj\app is application directory. Under this i have
'adminmedia', 'media' and 'templates' directories. So static files are
here: C:\dev\proj\app\media.
css file is here: C:\dev\proj\app\media\css\styles.css
settings file is here: C:\dev\proj\settings.py

like i said i now have MEDIA_ROOT set to C:\dev\proj\app, but still
not working. In template i was told to use .

MEDIA_URL not MEDIA_ROOT

regardless, do i have to pass context for MEDIA_URL in view so
template knows what it is?? is that the problem?

Thanks for helping, btw. Much appreciated.



On Jan 22, 11:57 am, Puneet Madaan  wrote:
> well at my side it works well on both *nix and windoof platforms... here is
> what I use on my projects...
>
> settings.py
> --
> import platform
> import os
>
> PROJECT_DIR = os.path.dirname( os.path.abspath(__file__))
> MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static')
> ---
>
> urls.py
> -
> from django.conf.urls.defaults import *
> from django.contrib import admin
> from django.conf import settings
>
> urlpatterns = patterns('',
>     #urls for your project
>     (r'^static/(?P.*)$', 'django.views.static.serve',
>         {'document_root': settings.MEDIA_ROOT}),
> )
> 
> where i use a directory named 'static' residing in same folder, where i have
> my settings.py   can you please place 'print MEDIA_ROOT' inside your
> settings.py and check the terminal the path is spilts out ? because your '-'
> convention before '-\media' is sort confusing, and its missing before
> manage.py and settings.py  is media folder residing really in the same
> directory where settings.py ?
>
> c:\dev
>
>
>
> >   -\proj
> >      __init__.py
> >      manage.py
> >      settings.py
> >      urls.py
> >      -\app
> >      -__init__.py
> >      -admin.py
> >      -models.py
> >      -views.py
> >      -\adminmedia
> >      -\media
> >        -\css
> >          -styles.css
> >        -\images
> >      -\templates
> >        -base.html
> >        -index.html
>
> if 'print MEDIA_ROOT' spilts out a path different from your media folder,
> then you know where is the problem ..
>
> Greetings,
> Puneet
>
>
>
> On Thu, Jan 22, 2009 at 5:40 PM, john  wrote:
>
> > Thanks but no change.
>
> > On Jan 22, 11:30 am, Puneet Madaan  wrote:
> > > beside  > href="{MEDIA_URL}css/styles.css">
> > > you need to correct settings.py to
>
> > > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))
>
> > > On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:
>
> > > > Thanks but no change.
>
> > > > On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> > > > > change
> > > > > 
> > > > > to
> > > > >  > href="{MEDIA_URL}css/styles.css">
>
> > > > > Dj Gilcrease
> > > > > OpenRPG Developer
> > > > > ~~http://www.openrpg.com
>
> > > > > On Thu, Jan 22, 2009 at 8:53 AM, john 
> > wrote:
>
> > > > > > No matter what i do i can't get my css to load. 100% Frustrated
> > with
> > > > > > Django. My index page loads when i requesthttp://
> > 127.0.0.1:8000/but
> > > > > > it is not styled. Django dev server returns 404 in console for "GET
> > /
> > > > > > css/styles.css HTTP/1.1"
>
> > > > > > In my base template i have:
> > > > > > 
>
> > > > > > In my urls.py I have:
> > > > > > urlpatterns = patterns('',
> > > > > >     (r'^$', 'proj.app.views.index'),
> > > > > >     (r'^admin/(.*)', admin.site.root),
> > > > > >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > > > {'document_root': settings.MEDIA_ROOT}),
> > > > > > )
>
> > > > > > In my settings.py i have (among other things):
> > > > > > import os
> > > > > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> > > > > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> > > > > > MEDIA_URL = 'http://127.0.0.1:8000/media/'
> > > > > > ADMIN_MEDIA_PREFIX =  'adminmedia'
>
> > > > > > my directory structure in windows is:
>
> > > > > > c:\dev
> > > > > >   -\proj
> > > > > >      __init__.py
> > > > > >      manage.py
> > > > > >      settings.py
> > > > > >      urls.py
> > > > > >      -\app
> > > > > >      -__init__.py
> > > > > >      -admin.py
> > > > > >      -models.py
> > > > > >      -views.py
> > > > > >      -\adminmedia
> > > > > >      -\media
> > > > > >        -\css
> > > > > >          -styles.css
> > > > > >        -\images
> > > > > >      -\templates
> > > > > >        -base.html
> > > > > >        -index.html
>
> > > --
> > > If you spin an oriental man, does he become disoriented?
> > > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
>
> > > is der net süß » ε(●̮̮̃•̃)з
> > > -PM
>
> --
> If you spin an oriental man, does he become disoriented?
> (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
>

Re: Cannot serve static files

2009-01-22 Thread Dj Gilcrease

Sorry that should be {{MEDIA_URL}}


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 22, 2009 at 9:30 AM, Puneet Madaan  wrote:
> beside  you need to correct settings.py to
>
> SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))
>
>
> On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:
>>
>> Thanks but no change.
>>
>> On Jan 22, 11:02 am, Dj Gilcrease  wrote:
>> > change
>> > 
>> > to
>> > 
>> >
>> > Dj Gilcrease
>> > OpenRPG Developer
>> > ~~http://www.openrpg.com
>> >
>> > On Thu, Jan 22, 2009 at 8:53 AM, john  wrote:
>> >
>> > > No matter what i do i can't get my css to load. 100% Frustrated with
>> > > Django. My index page loads when i requesthttp://127.0.0.1:8000/but
>> > > it is not styled. Django dev server returns 404 in console for "GET /
>> > > css/styles.css HTTP/1.1"
>> >
>> > > In my base template i have:
>> > > 
>> >
>> > > In my urls.py I have:
>> > > urlpatterns = patterns('',
>> > > (r'^$', 'proj.app.views.index'),
>> > > (r'^admin/(.*)', admin.site.root),
>> > > (r'^media/(?P.*)$', 'django.views.static.serve',
>> > > {'document_root': settings.MEDIA_ROOT}),
>> > > )
>> >
>> > > In my settings.py i have (among other things):
>> > > import os
>> > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
>> > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
>> > > MEDIA_URL = 'http://127.0.0.1:8000/media/'
>> > > ADMIN_MEDIA_PREFIX =  'adminmedia'
>> >
>> > > my directory structure in windows is:
>> >
>> > > c:\dev
>> > >   -\proj
>> > >  __init__.py
>> > >  manage.py
>> > >  settings.py
>> > >  urls.py
>> > >  -\app
>> > >  -__init__.py
>> > >  -admin.py
>> > >  -models.py
>> > >  -views.py
>> > >  -\adminmedia
>> > >  -\media
>> > >-\css
>> > >  -styles.css
>> > >-\images
>> > >  -\templates
>> > >-base.html
>> > >-index.html
>>
>
>
>
> --
> If you spin an oriental man, does he become disoriented?
> (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
>
> is der net süß » ε(●̮̮̃•̃)з
> -PM
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread Puneet Madaan
well at my side it works well on both *nix and windoof platforms... here is
what I use on my projects...

settings.py
--
import platform
import os

PROJECT_DIR = os.path.dirname( os.path.abspath(__file__))
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'static')
---

urls.py
-
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings

urlpatterns = patterns('',
#urls for your project
(r'^static/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)

where i use a directory named 'static' residing in same folder, where i have
my settings.py   can you please place 'print MEDIA_ROOT' inside your
settings.py and check the terminal the path is spilts out ? because your '-'
convention before '-\media' is sort confusing, and its missing before
manage.py and settings.py  is media folder residing really in the same
directory where settings.py ?

c:\dev
>   -\proj
>  __init__.py
>  manage.py
>  settings.py
>  urls.py
>  -\app
>  -__init__.py
>  -admin.py
>  -models.py
>  -views.py
>  -\adminmedia
>  -\media
>-\css
>  -styles.css
>-\images
>  -\templates
>-base.html
>-index.html
>

if 'print MEDIA_ROOT' spilts out a path different from your media folder,
then you know where is the problem ..

Greetings,
Puneet

On Thu, Jan 22, 2009 at 5:40 PM, john  wrote:

>
> Thanks but no change.
>
> On Jan 22, 11:30 am, Puneet Madaan  wrote:
> > beside  href="{MEDIA_URL}css/styles.css">
> > you need to correct settings.py to
> >
> > SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))
> >
> >
> >
> > On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:
> >
> > > Thanks but no change.
> >
> > > On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> > > > change
> > > > 
> > > > to
> > > >  href="{MEDIA_URL}css/styles.css">
> >
> > > > Dj Gilcrease
> > > > OpenRPG Developer
> > > > ~~http://www.openrpg.com
> >
> > > > On Thu, Jan 22, 2009 at 8:53 AM, john 
> wrote:
> >
> > > > > No matter what i do i can't get my css to load. 100% Frustrated
> with
> > > > > Django. My index page loads when i requesthttp://
> 127.0.0.1:8000/but
> > > > > it is not styled. Django dev server returns 404 in console for "GET
> /
> > > > > css/styles.css HTTP/1.1"
> >
> > > > > In my base template i have:
> > > > > 
> >
> > > > > In my urls.py I have:
> > > > > urlpatterns = patterns('',
> > > > > (r'^$', 'proj.app.views.index'),
> > > > > (r'^admin/(.*)', admin.site.root),
> > > > > (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > > {'document_root': settings.MEDIA_ROOT}),
> > > > > )
> >
> > > > > In my settings.py i have (among other things):
> > > > > import os
> > > > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> > > > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> > > > > MEDIA_URL = 'http://127.0.0.1:8000/media/'
> > > > > ADMIN_MEDIA_PREFIX =  'adminmedia'
> >
> > > > > my directory structure in windows is:
> >
> > > > > c:\dev
> > > > >   -\proj
> > > > >  __init__.py
> > > > >  manage.py
> > > > >  settings.py
> > > > >  urls.py
> > > > >  -\app
> > > > >  -__init__.py
> > > > >  -admin.py
> > > > >  -models.py
> > > > >  -views.py
> > > > >  -\adminmedia
> > > > >  -\media
> > > > >-\css
> > > > >  -styles.css
> > > > >-\images
> > > > >  -\templates
> > > > >-base.html
> > > > >-index.html
> >
> > --
> > If you spin an oriental man, does he become disoriented?
> > (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
> >
> > is der net süß » ε(●̮̮̃•̃)з
> > -PM
> >
>


-- 
If you spin an oriental man, does he become disoriented?
(-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu

is der net süß » ε(●̮̮̃•̃)з
-PM

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread john

Thanks but no change.

On Jan 22, 11:30 am, Puneet Madaan  wrote:
> beside  href="{MEDIA_URL}css/styles.css">
> you need to correct settings.py to
>
> SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))
>
>
>
> On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:
>
> > Thanks but no change.
>
> > On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> > > change
> > > 
> > > to
> > > 
>
> > > Dj Gilcrease
> > > OpenRPG Developer
> > > ~~http://www.openrpg.com
>
> > > On Thu, Jan 22, 2009 at 8:53 AM, john  wrote:
>
> > > > No matter what i do i can't get my css to load. 100% Frustrated with
> > > > Django. My index page loads when i requesthttp://127.0.0.1:8000/but
> > > > it is not styled. Django dev server returns 404 in console for "GET /
> > > > css/styles.css HTTP/1.1"
>
> > > > In my base template i have:
> > > > 
>
> > > > In my urls.py I have:
> > > > urlpatterns = patterns('',
> > > >     (r'^$', 'proj.app.views.index'),
> > > >     (r'^admin/(.*)', admin.site.root),
> > > >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > > > {'document_root': settings.MEDIA_ROOT}),
> > > > )
>
> > > > In my settings.py i have (among other things):
> > > > import os
> > > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> > > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> > > > MEDIA_URL = 'http://127.0.0.1:8000/media/'
> > > > ADMIN_MEDIA_PREFIX =  'adminmedia'
>
> > > > my directory structure in windows is:
>
> > > > c:\dev
> > > >   -\proj
> > > >      __init__.py
> > > >      manage.py
> > > >      settings.py
> > > >      urls.py
> > > >      -\app
> > > >      -__init__.py
> > > >      -admin.py
> > > >      -models.py
> > > >      -views.py
> > > >      -\adminmedia
> > > >      -\media
> > > >        -\css
> > > >          -styles.css
> > > >        -\images
> > > >      -\templates
> > > >        -base.html
> > > >        -index.html
>
> --
> If you spin an oriental man, does he become disoriented?
> (-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu
>
> is der net süß » ε(●̮̮̃•̃)з
> -PM
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread Puneet Madaan
beside 
you need to correct settings.py to

SETTINGS_FILE_FOLDER = os.path.dirname( os.path.abspath(__file__))


On Thu, Jan 22, 2009 at 5:26 PM, john  wrote:

>
> Thanks but no change.
>
> On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> > change
> > 
> > to
> > 
> >
> > Dj Gilcrease
> > OpenRPG Developer
> > ~~http://www.openrpg.com
> >
> > On Thu, Jan 22, 2009 at 8:53 AM, john  wrote:
> >
> > > No matter what i do i can't get my css to load. 100% Frustrated with
> > > Django. My index page loads when i requesthttp://127.0.0.1:8000/but
> > > it is not styled. Django dev server returns 404 in console for "GET /
> > > css/styles.css HTTP/1.1"
> >
> > > In my base template i have:
> > > 
> >
> > > In my urls.py I have:
> > > urlpatterns = patterns('',
> > > (r'^$', 'proj.app.views.index'),
> > > (r'^admin/(.*)', admin.site.root),
> > > (r'^media/(?P.*)$', 'django.views.static.serve',
> > > {'document_root': settings.MEDIA_ROOT}),
> > > )
> >
> > > In my settings.py i have (among other things):
> > > import os
> > > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> > > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> > > MEDIA_URL = 'http://127.0.0.1:8000/media/'
> > > ADMIN_MEDIA_PREFIX =  'adminmedia'
> >
> > > my directory structure in windows is:
> >
> > > c:\dev
> > >   -\proj
> > >  __init__.py
> > >  manage.py
> > >  settings.py
> > >  urls.py
> > >  -\app
> > >  -__init__.py
> > >  -admin.py
> > >  -models.py
> > >  -views.py
> > >  -\adminmedia
> > >  -\media
> > >-\css
> > >  -styles.css
> > >-\images
> > >  -\templates
> > >-base.html
> > >-index.html
> >
>


-- 
If you spin an oriental man, does he become disoriented?
(-: ¿ʇɥǝɹpɹǝʌ ɟdoʞ uǝp ɹıp ɥɔı ,qɐɥ 'ɐɐu

is der net süß » ε(●̮̮̃•̃)з
-PM

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread john

Thanks but no change.

On Jan 22, 11:02 am, Dj Gilcrease  wrote:
> change
> 
> to
> 
>
> Dj Gilcrease
> OpenRPG Developer
> ~~http://www.openrpg.com
>
> On Thu, Jan 22, 2009 at 8:53 AM, john  wrote:
>
> > No matter what i do i can't get my css to load. 100% Frustrated with
> > Django. My index page loads when i requesthttp://127.0.0.1:8000/but
> > it is not styled. Django dev server returns 404 in console for "GET /
> > css/styles.css HTTP/1.1"
>
> > In my base template i have:
> > 
>
> > In my urls.py I have:
> > urlpatterns = patterns('',
> >     (r'^$', 'proj.app.views.index'),
> >     (r'^admin/(.*)', admin.site.root),
> >     (r'^media/(?P.*)$', 'django.views.static.serve',
> > {'document_root': settings.MEDIA_ROOT}),
> > )
>
> > In my settings.py i have (among other things):
> > import os
> > SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> > MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> > MEDIA_URL = 'http://127.0.0.1:8000/media/'
> > ADMIN_MEDIA_PREFIX =  'adminmedia'
>
> > my directory structure in windows is:
>
> > c:\dev
> >   -\proj
> >      __init__.py
> >      manage.py
> >      settings.py
> >      urls.py
> >      -\app
> >      -__init__.py
> >      -admin.py
> >      -models.py
> >      -views.py
> >      -\adminmedia
> >      -\media
> >        -\css
> >          -styles.css
> >        -\images
> >      -\templates
> >        -base.html
> >        -index.html
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread Dj Gilcrease

change

to


Dj Gilcrease
OpenRPG Developer
~~http://www.openrpg.com



On Thu, Jan 22, 2009 at 8:53 AM, john  wrote:
>
> No matter what i do i can't get my css to load. 100% Frustrated with
> Django. My index page loads when i request http://127.0.0.1:8000/ but
> it is not styled. Django dev server returns 404 in console for "GET /
> css/styles.css HTTP/1.1"
>
> In my base template i have:
> 
>
> In my urls.py I have:
> urlpatterns = patterns('',
> (r'^$', 'proj.app.views.index'),
> (r'^admin/(.*)', admin.site.root),
> (r'^media/(?P.*)$', 'django.views.static.serve',
> {'document_root': settings.MEDIA_ROOT}),
> )
>
> In my settings.py i have (among other things):
> import os
> SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
> MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
> MEDIA_URL = 'http://127.0.0.1:8000/media/'
> ADMIN_MEDIA_PREFIX =  'adminmedia'
>
> my directory structure in windows is:
>
> c:\dev
>   -\proj
>  __init__.py
>  manage.py
>  settings.py
>  urls.py
>  -\app
>  -__init__.py
>  -admin.py
>  -models.py
>  -views.py
>  -\adminmedia
>  -\media
>-\css
>  -styles.css
>-\images
>  -\templates
>-base.html
>-index.html
>
>
>
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Cannot serve static files

2009-01-22 Thread David Zhou

On Thu, Jan 22, 2009 at 10:53 AM, john  wrote:
>
> No matter what i do i can't get my css to load. 100% Frustrated with
> Django. My index page loads when i request http://127.0.0.1:8000/ but
> it is not styled. Django dev server returns 404 in console for "GET /
> css/styles.css HTTP/1.1"

Try doing:




-- dz

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Cannot serve static files

2009-01-22 Thread john

No matter what i do i can't get my css to load. 100% Frustrated with
Django. My index page loads when i request http://127.0.0.1:8000/ but
it is not styled. Django dev server returns 404 in console for "GET /
css/styles.css HTTP/1.1"

In my base template i have:


In my urls.py I have:
urlpatterns = patterns('',
 (r'^$', 'proj.app.views.index'),
 (r'^admin/(.*)', admin.site.root),
 (r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT}),
)

In my settings.py i have (among other things):
import os
SETTINGS_FILE_FOLDER = os.path.dirname(__file__)
MEDIA_ROOT = os.path.join(SETTINGS_FILE_FOLDER, 'media')
MEDIA_URL = 'http://127.0.0.1:8000/media/'
ADMIN_MEDIA_PREFIX =  'adminmedia'

my directory structure in windows is:

c:\dev
   -\proj
  __init__.py
  manage.py
  settings.py
  urls.py
  -\app
  -__init__.py
  -admin.py
  -models.py
  -views.py
  -\adminmedia
  -\media
-\css
  -styles.css
-\images
  -\templates
-base.html
-index.html




--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: serve static files

2008-06-17 Thread Molly

I think I may have figured out the problem.. I needed my admin_media
folder to be in my media folder

Thanks for the help :)
I appreciate both of your responses!

Molly


On Jun 17, 1:37 pm, "Norman Harman" <[EMAIL PROTECTED]> wrote:
> Molly wrote:
> > How would I call the static file in my browser??
>
> By typing in the url to the static file directly in the address bar.
>
> For example if your server is example.com, root of django app is myapp,
> and images are in img dir, and image is named myjp.jpg  the url would be
>
> http:://example.com/myapp/media/img/myjpg.jpg
>
>  From your description it sounds like the css is not being found.  I'd
> look in the HTML source(as seen by browser, with firefox ctrl-u, with IE
> install Firefox) find line(s) that include css.  They probably look
> something like this.
>
>  href="http://yui.yahooapis.com/2.3.1/build/calendar/assets/calendar.css"; />
>
> then see if you access(copy it to address bar, hit 
> return)http://yui.yahooapis.com/2.3.1/build/calendar/assets/calendar.css
>
> Either the url(s) in your templates point to wrong place, or the
> urls/document_roots in urlpatterns are wrong, or something else is wrong ;)
>
> btw hard coding a path "C:\dev\incidents\admin_media" in your
> urlpatterns is probably a bad thing to do.  As whoever uses your
> app/where ever you deploy it for production is unlikely to install the
> app in the same place you do on your dev machine.
>
> --
> Norman J. Harman Jr.
> Senior Web Specialist, Austin American-Statesman
> ___
> You've got fun!  Check out Austin360.com for all the entertainment
> info you need to live it up in the big city!
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: serve static files

2008-06-17 Thread Norman Harman

Molly wrote:
> How would I call the static file in my browser??

By typing in the url to the static file directly in the address bar.

For example if your server is example.com, root of django app is myapp, 
and images are in img dir, and image is named myjp.jpg  the url would be

http:://example.com/myapp/media/img/myjpg.jpg

 From your description it sounds like the css is not being found.  I'd 
look in the HTML source(as seen by browser, with firefox ctrl-u, with IE 
install Firefox) find line(s) that include css.  They probably look 
something like this.

http://yui.yahooapis.com/2.3.1/build/calendar/assets/calendar.css"; />

then see if you access(copy it to address bar, hit return) 
http://yui.yahooapis.com/2.3.1/build/calendar/assets/calendar.css

Either the url(s) in your templates point to wrong place, or the 
urls/document_roots in urlpatterns are wrong, or something else is wrong ;)

btw hard coding a path "C:\dev\incidents\admin_media" in your 
urlpatterns is probably a bad thing to do.  As whoever uses your 
app/where ever you deploy it for production is unlikely to install the 
app in the same place you do on your dev machine.


-- 
Norman J. Harman Jr.
Senior Web Specialist, Austin American-Statesman
___
You've got fun!  Check out Austin360.com for all the entertainment
info you need to live it up in the big city!

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: serve static files

2008-06-17 Thread Molly

How would I call the static file in my browser??

Sorry, i'm still a beginner! :P

Thanks for the response :)

Molly

On Jun 17, 12:16 pm, chris vigelius <[EMAIL PROTECTED]>
wrote:
> Am Dienstag, 17. Juni 2008 17:22:46 schrieb Molly:
>
> > I created a django app and turned it into a stand alone app.
>
> > Everything is working, except for the look of the page is all messed
> > up.
>
> what happens if you call one of the static files directly in your browser?
> Does the path to the static files appear correctly in the source of your
> page?
>
> regards,
>  chris
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: serve static files

2008-06-17 Thread chris vigelius

Am Dienstag, 17. Juni 2008 17:22:46 schrieb Molly:
> I created a django app and turned it into a stand alone app.
>
> Everything is working, except for the look of the page is all messed
> up.

what happens if you call one of the static files directly in your browser? 
Does the path to the static files appear correctly in the source of your 
page?

regards,
 chris

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



serve static files

2008-06-17 Thread Molly

I created a django app and turned it into a stand alone app.

Everything is working, except for the look of the page is all messed
up.

I need to serve static files (I think) in urls.py but somehow I am
messing up my code:

---

from django.conf.urls.defaults import *

urlpatterns = patterns('',
(r'^admin/', include('django.contrib.admin.urls')),
(r'^media/(?P.*)$', 'django.views.static.serve',
{'document_root': r'C:\dev\incidents\media', 'show_indexes': True}),
(r'^admin_media/(?P.*)$', 'django.views.static.serve',
{'document_root': r'C:\dev\incidents\admin_media', 'show_indexes':
True}),
)

---

I can't see any problems..
I would appreciate any help you can give me!

Thanks :)
Molly
--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Apache does not serve static files from document root

2007-08-20 Thread Peter Melvyn

On 8/20/07, Graham Dumpleton <[EMAIL PROTECTED]> wrote:

> Have you read the mod_python documentation on Django site? It gives an
> example, which modified for your case would be:
>
> 
> SetHandler None
> 
>
> The important bit is the SetHandler directive. Have you done that?

Yes, I did. Setting  handler to default-handler has the same effect as
setting it to None. I tried both values.


> Post what your Apache configuration snippet for setting up Django
> looks like.

SOLVED. My friend has localized a problem: The reason was
misinterpretation of Apache's manual sentence:  " directives
are processed in the order they appear in the configuration file"

It does not mean I should put a  *before*
mod_python's , but *behind* it, because first, "/" locations
 is evaluated as matched, next the "/wssmedia" is matched and
overrides first one.

Hence the working httpd.conf snippet looks like:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE bizweb.server_settings
PythonDebug On
PythonPath "[r'C:\\.WKS-PF\\PRJ\\ECLIPSE\\Django\\src'] + sys.path"



SetHandler default-handler



Thank you for your help and I hope this off-topic thread would be
usefull for somebody else who meets the similiar problems on Apache
side.


Peter

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Apache does not serve static files from document root

2007-08-20 Thread Graham Dumpleton

On Aug 21, 3:21 am, "Peter Melvyn" <[EMAIL PROTECTED]> wrote:
> On 8/20/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> > Not really Django related, so I'll do this briefly...
>
> Yes, I know. I appreciate your prompt reply. Thanks.
>
> > In this case you'll probably want to add another Location section before
> > this one to handle things to WWW-ROOT/bizweb explicitly (whatever URL is
> > meant to map to that filesystem location). Note (read the Apache docs)
> > that Location sections are processed in order from top to bottom in the
> > config file.
>
> Yes, I would. I played with Apache httpd.conf almost all afternoon to
> do achieve this, but with no success: once there is  or
>  setting handler tomod_python, all requests
> are routed to it and it seems that all precedent  are
> ignored.
>
> If I changedmod_python's, precedent  take
> effect, but it break functionality of Django app.
>
> ###
>
> Regardless of Apache config problem, how to handle following URLs by
> Django 
> application:http://www.mysite.comhttp://www.mysite.com/http://www.mysite.com/index.htmhttp://www.mysite.com/index.htmlhttp://www.mysite.com/wss/.*$
>
> Currently I route different url patterns of home page to the same view
> - there is no problem. With development server as well.
>
> But I don't know how to config Apache this way:
> if URL starts with "/wssmedia/":
> use default_handler
> else:
> usemod_python(Django)

Have you read the mod_python documentation on Django site? It gives an
example, which modified for your case would be:


SetHandler None


The important bit is the SetHandler directive. Have you done that?

Post what your Apache configuration snippet for setting up Django
looks like.

Graham


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Apache does not serve static files from document root

2007-08-20 Thread Peter Melvyn

On 8/20/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:

> Not really Django related, so I'll do this briefly...

Yes, I know. I appreciate your prompt reply. Thanks.


> In this case you'll probably want to add another Location section before
> this one to handle things to WWW-ROOT/bizweb explicitly (whatever URL is
> meant to map to that filesystem location). Note (read the Apache docs)
> that Location sections are processed in order from top to bottom in the
> config file.

Yes, I would. I played with Apache httpd.conf almost all afternoon to
do achieve this, but with no success: once there is  or
 setting handler to mod_python, all requests
are routed to it and it seems that all precedent  are
ignored.

If I changed mod_python's , precedent  take
effect, but it break functionality of Django app.

###

Regardless of Apache config problem, how to handle following URLs by
Django application:
http://www.mysite.com
http://www.mysite.com/
http://www.mysite.com/index.htm
http://www.mysite.com/index.html
http://www.mysite.com/wss/.*$

Currently I route different url patterns of home page to the same view
- there is no problem. With development server as well.

But I don't know how to config Apache this way:
if URL starts with "/wssmedia/":
use default_handler
else:
use mod_python (Django)


Peter

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: Apache does not serve static files from document root

2007-08-20 Thread Malcolm Tredinnick

On Mon, 2007-08-20 at 12:17 +0200, Peter Melvyn wrote:
> Hi all,
> 
> I'm trying to migrate my Django project from dev. server to Apache on
> the same machine running Windows. Content generated by Django is OK,
> but no static file from DocumentRoot is served.
> 
> My Apache & mod-python is configured this way:
> 
> 

Not really Django related, so I'll do this briefly...

This says that this location block will be serving *everything* for this
website. That is, everything starting with '/' will be processed by
whatever is in the Location block. You clearly don't want this in your
case.

In particular, the contents of this Location block say that everything
under this URL should be give to the mod_python handler, which is
exactly what is happening.

In this case you'll probably want to add another Location section before
this one to handle things to WWW-ROOT/bizweb explicitly (whatever URL is
meant to map to that filesystem location). Note (read the Apache docs)
that Location sections are processed in order from top to bottom in the
config file.

> SetHandler python-program
> PythonHandler django.core.handlers.modpython
> SetEnv DJANGO_SETTINGS_MODULE bizweb.server_settings
> PythonDebug On
> PythonPath "[r'C:\\.WKS-PF\\PRJ\\ECLIPSE\\Django\\src'] + sys.path"
> 

Regards,
Malcolm

-- 
Why can't you be a non-conformist like everyone else? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Apache does not serve static files from document root

2007-08-20 Thread Peter Melvyn

Hi all,

I'm trying to migrate my Django project from dev. server to Apache on
the same machine running Windows. Content generated by Django is OK,
but no static file from DocumentRoot is served.

My Apache & mod-python is configured this way:


SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE bizweb.server_settings
PythonDebug On
PythonPath "[r'C:\\.WKS-PF\\PRJ\\ECLIPSE\\Django\\src'] + sys.path"


DocumentRoot "V:/WWW-ROOT/bizweb"


Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all


###

If I tried navigate to particular file, eg.
http://localhost/wssmedia/css/img/arr0_blue.gif
and I got mod_python error:
[...]
DocumentRoot:   'V:/WWW-ROOT/bizweb'

URI:'/wssmedia/css/img/arr0_blue.gif'
Location:   '/'
Directory:  None
Filename:   'V:/WWW-ROOT/bizweb/wssmedia/css/img/arr0_blue.gif'
PathInfo:   ''

Phase:  'PythonHandler'
Handler:'django.core.handlers.modpython'
[...]
Traceback (most recent call last):
[...]
AttributeError: 'module' object has no attribute 'handler404'


Filename V:/WWW-ROOT/bizweb/wssmedia/css/img/arr0_blue.gif is correct
and the file *does* exist, but Apache did not serve it - it looks like
the Apache routes all /wssmedia/ requests to mod_python, instead
serving them itself.

###

Please, could anybody advice what is wrong in my Apache and/or Django settings?


Thanks in advance,
Peter

--~--~-~--~~~---~--~~
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?hl=en
-~--~~~~--~~--~--~---



Re: ANN: New document: How to serve static files

2005-11-27 Thread Adrian Holovaty

On 11/27/05, Christopher Lenz <[EMAIL PROTECTED]> wrote:
> > How to serve static files
> > http://www.djangoproject.com/documentation/static_files/
>
> Can you maybe elaborate on why this approach is considered insecure?

Mainly because it hasn't been security-audited, doesn't have any error
handling, etc.

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org


Re: ANN: New document: How to serve static files

2005-11-27 Thread Christopher Lenz


Am 27.11.2005 um 15:48 schrieb Adrian Holovaty:

A commonly asked question is how to serve static files with Django.
Here's the answer, finally documented.

How to serve static files
http://www.djangoproject.com/documentation/static_files/


Can you maybe elaborate on why this approach is considered insecure?

Thanks,
Chris
--
Christopher Lenz
  cmlenz at gmx.de
  http://www.cmlenz.net/



Re: ANN: New document: How to serve static files

2005-11-27 Thread Fat

it's very useful!
good job


ANN: New document: How to serve static files

2005-11-27 Thread Adrian Holovaty

A commonly asked question is how to serve static files with Django.
Here's the answer, finally documented.

How to serve static files
http://www.djangoproject.com/documentation/static_files/

Adrian

--
Adrian Holovaty
holovaty.com | djangoproject.com | chicagocrime.org