Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have set up Django 1.3 onto my BlueHost account with Python 2.6 and it is working well except when I enter the admin area it is void of any css/formatting - all I get is text. In my research I found that I need to set up the web server to 'serve' the static files, Django does not do this (except when using the Django development server).

I have made several attempts but no success... Here are the current settings:

Settings.py:

ADMIN_MEDIA_PREFIX = '/static/admin/'

.htaccess:

AddHandler fcgid-script .fcgi
RewriteEngine On
Rewritebase /
RewriteRule ^(static/admin/.*)$ [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /django/test1/mysite.fcgi/$1 [QSA,L]

There is also a symlink at the projects static files ../static/admin/ to ../django/contrib/admin/media

You can see the resulting page at http://www.foreignlanguageflashcards.com/django/test1/admin/ Thanks.

share|improve this question

migrated from stackoverflow.com May 27 '11 at 22:14

This question came from our site for professional and enthusiast programmers.

1 Answer 1

up vote 1 down vote accepted

With some help from http://blog.ruedaminute.com/2011/01/2011-installation-instructions-for-django-on-bluehost/ I was able to get it working. I gave up on using symlinks and:

  1. copied the admin media files from /.local/lib/python2.6/site-packages/django/contrib/admin/media to http://www.foo.com/django/project/static/admin/media/ (part of my problem earlier was confusing the django project directory with the public url directory)
  2. edited settings.py to include: ADMIN_MEDIA_PREFIX = '/django/project/static/admin/media/'
  3. cleaned up the htaccess to look like:
AddHandler fcgid-script .fcgi
RewriteEngine On
Rewritebase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /django/project/mysite.fcgi/$1 [QSA,L]
  1. If it helps, here is the fcgi script:
#!/usr/bin/python2.6
import sys, os
# Add a custom Python path.
sys.path.insert(0, "/home1/username/.local/lib/python2.6")
sys.path.insert(0, "/home1/username/django_projects")

# Switch to the directory of your project. (Optional.)
# os.chdir("/home1/username/django_projects/project") 

# Set the DJANGO_SETTINGS_MODULE environment variable.
os.environ['DJANGO_SETTINGS_MODULE'] = "project.settings"

from django.core.servers.fastcgi import runfastcgi
runfastcgi(method="threaded", daemonize="false")
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.