First time here? Check out the FAQ!
1

Static files (css, js and images) not served
 

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 ?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
kintali's avatar
141
kintali
asked 12 years ago
Evgeny's avatar
13.2k
Evgeny
updated 12 years ago

Comments

see more comments

3 Answers

1

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

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
tristan's avatar
95
tristan
answered 12 years ago
Evgeny's avatar
13.2k
Evgeny
updated 12 years ago
link

Comments

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

Evgeny's avatar Evgeny (12 years ago)

Yes that right... oops...

tristan's avatar tristan (12 years ago)

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's avatar kintali (12 years ago)

And the virtualhost ?

tristan's avatar tristan (12 years ago)

I don't see virtualhost in settings.py

kintali's avatar kintali (12 years ago)
see more comments
1

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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 12 years ago, updated 12 years ago
link

Comments

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

kintali's avatar kintali (12 years ago)

Is DEBUG setting True or False?

Evgeny's avatar Evgeny (12 years ago)

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's avatar Evgeny (12 years ago)

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's avatar kintali (12 years ago)

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's avatar Evgeny (12 years ago)
see more comments
0

Another solution is a symlink: from the public dir, where you may have your .htaccess and askbot.fcgi, run:

ln -s /path/to/static m

Of course, you need to run python manage.py collectstatic too.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
ProfGra's avatar
36
ProfGra
answered 10 years ago
link

Comments

see more comments