Ask Your Question
1

Static files (css, js and images) not served

asked 2012-04-29 14:06:59 -0500

kintali gravatar image kintali flag of United States
111 5 1 9
http://www.cs.princeton.e...

updated 2012-04-29 14:13:13 -0500

Evgeny gravatar image Evgeny flag of Chile
11024 50 84 182
http://askbot.org/

I checked out askbot code from github using the following command

git clone git://github.com/ASKBOT/askbot-devel.git

And ran the following command

python setup.py develop

I deployed it on my webserver by following the instructions at http://askbot.org/doc/index.html When I visit my website it looks like the following Image.

http://dl.dropbox.com/u/750152/askbot.png

All the css rendering is gone. Am I missing some step ?

delete close flag offensive retag edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-04-29 14:12:25 -0500

Evgeny gravatar image Evgeny flag of Chile
11024 50 84 182
http://askbot.org/

updated 2012-04-29 14:13:45 -0500

The issue you are seeing is that static files are not served with DEBUG=False, so the site appears unstyled.

With runserver, please use DEBUG=True, as in production mode static files are not served by django.

Please run python manage.py collectstatic - to collect the static files for production and configure your webserver to serve the static resources directly.

link publish delete flag offensive edit

Comments

I ran python manage.py collectstatic. How do I configure to serve static resources directly ?

kintali ( 2012-04-29 14:38:13 -0500 )edit

Is DEBUG setting True or False?

Evgeny ( 2012-04-29 14:39:34 -0500 )edit

Oh, you need to add Alias settings (or equivalent) to your webserver configuration. For Apache you need something like Alias /static/ /path/to/django-project/static/, where the second path will be specific to your setup.

Evgeny ( 2012-04-29 14:40:31 -0500 )edit

DEBUG=False. I am using the same configuration file mentioned at http://askbot.org/doc/deployment.html Is there an issue with permissions ? What permissions are needed for django-project and other directories ?

kintali ( 2012-04-29 14:54:02 -0500 )edit

With DEBUG=False you have to serve static files yourself - via the webserver. With DEBUG=True django will serve static files. For production it is very inefficient to serve static files via python (django). It could be that files are inaccessible to the webserver process. It could be for example because one of the directories above the static files being inaccessible to the effective user that runs the webserver process.

Evgeny ( 2012-04-29 15:04:29 -0500 )edit
1

answered 2012-04-29 14:41:24 -0500

tristan gravatar image tristan flag of France
85 2 1 8

updated 2012-04-29 15:00:27 -0500

Evgeny gravatar image Evgeny flag of Chile
11024 50 84 182
http://askbot.org/

If you are using Apache, in the settings.py file, modify STATIC_URL with '/static/' and run python manage.py collectstatic.
Then follow http://askbot.org/doc/deployment.html

link publish delete flag offensive edit

Comments

STATIC_URL should be '/static/' - with the leading and the trailing slash.

Evgeny ( 2012-04-29 14:49:21 -0500 )edit

Yes that right... oops...

tristan ( 2012-04-29 14:55:35 -0500 )edit

I have the following settings : MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles') MEDIA_URL = '/upfiles/' STATIC_URL = '/m/'#this must be different from MEDIA_URL

PROJECT_ROOT = os.path.dirname(__file__) STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

kintali ( 2012-04-29 14:57:13 -0500 )edit

And the virtualhost ?

tristan ( 2012-04-29 15:04:26 -0500 )edit

I don't see virtualhost in settings.py

kintali ( 2012-04-29 15:16:59 -0500 )edit

virtual host in part of the webserver configuration, not django.

Evgeny ( 2012-04-29 15:18:29 -0500 )edit

in /etc/apache2/sites-available/

tristan ( 2012-04-29 15:26:06 -0500 )edit

I have <VirtualHost *:80>. When I replace * with my actual IP address, I get a warning saying "[warn] NameVirtualHost *:80 has no VirtualHosts". Is this a problem ?

kintali ( 2012-04-29 16:03:59 -0500 )edit

in /etc/apache2/apache2.conf, last line, add : NameVirtualHost your_ip:80

tristan ( 2012-04-29 16:07:46 -0500 )edit

in /etc/apache2/apache2.conf, last line, add :<br />

tristan ( 2012-04-29 16:07:47 -0500 )edit

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-04-29 14:06:59 -0500

Seen: 280 times

Last updated: Apr 29 '12