Apache is not serving static files from Django app -


i don't know what's wrong in virtualhost django project question no matter modification on file stills output same in error log apache , not load css or js files, can see apache looking static , media file in root web folder: /var/www

[fri may 30 00:58:08 2014] [error] [client 192.168.1.145] file not exist: /var/www/static, referer: http://192.168.1.143/dgp/login/ 

i set virtual host file follows:

  wsgipythonpath /var/www/dgp_python2_7/bin/python2.7:/var/www/dgp_python2_7/lib/python2.7/site-packages   wsgiscriptalias /dgp /var/www/dgp/dgp/dgp/wsgi.py    <virtualhost 127.0.0.1:80>       servername www.dgp.dev       serveralias dgp.dev        aliasmatch ^/([^/]*\.css) /var/www/dgp/dgp/static/$1       alias /media/ /var/www/dgp/dgp/media/      alias /static/ /var/www/dgp/dgp/static/      alias /images/ /var/www/dgp/dgp/images/      <directory /var/www/dgp/dgp/static/>       order deny,allow       allow     </directory>      <directory /var/www/dgp/dgp/media/>       order deny,allow       allow     </directory>       errorlog /var/www/dgp/dgp/error.log      customlog /var/www/dgp/dgp/access.log combined   </virtualhost> 

and in settings.py static_root '/var/www/dgp/dgp/static/' located css content.

how can tell apache or django looking proper directory '/var/www/dgp/dgp/static/'? it's driving me crazy, don't understand how elemental in development it's complex production.

regards!

edit solution

the problem didn't disable default site debian apache (that version i'm working for) , has method stablish virtualhost, @ beginning have disable default site follow command: a2dissite defaultand works charm!

you can tell static files being looked in project's rendered html. view source in browser , stylesheet or javascript include, full path file?

my guess, have run django's collect static script, collect static scripts in of project's app , put them 1 location. core part of deploying django projects , unavoidable if use multiple "apps" in project.

in terminal go django projects root folder , type this:

python manage.py collectstatic 

read more @ https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/


Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -