0

I have tried Django for a few days, and I'm trying to set up a production project with apache. I have followed the official tutorial at

http://docs.djangoproject.com/en/1.3/intro/tutorial01/

Everything works just fine with the development server but with apache, I lose every admin style.

I have read similar posts for this issue, without any success from now.

Django admin has no style Django: ugly admin interface

It may be a rights issue, but I have copied the directory where the media files are stored

/usr/share/pyshared/django/contrib/admin/media/

to the site I server under /data

/data/mysite/ /data/media/ /data/templates/

I have tried different values for /data/mysite/settings.py

/media/, /data/media/,

with the Alias item in the apache configuration as well.

Here is my apache configuration ` ServerAdmin webmaster@localhost

DocumentRoot /data/sites/accounts/

Alias /media/ /usr/share/pyshared/django/contrib/admin/media/

<Directory />
    Options None
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location />
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined

`

I have the intuition that this is a right issue, but /data/media/ and /data/templates have the same rights/owner and I can modify any template without any problem, and still no style for admin. Each file served by apache belongs to root:www-data, and 750 for the files, 710 for dirs.

I really thank any of you for any idea helping me to solve this issue :)

EDIT: I have used for apache the module mod_python. Don't hesitate to ask for any further details

Thx a lot!

Community
  • 1
  • 1
philippe
  • 2,949
  • 4
  • 20
  • 34

2 Answers2

0

This is definitely an Apache issue. Your Alias is outside of your DocumentRoot, but you're not specifying access to it:

http://httpd.apache.org/docs/2.0/mod/mod_alias.html#alias

P.S.: If you don't use a tool like Firebug, you could enter the URL of let's say one of the admin css files, to see in your browser what the response is (that's at least more info than "no styles").

Danny W. Adair
  • 12,498
  • 4
  • 43
  • 49
  • Thanks a lot for your answer. This is indeed an apache issue, I can read from the apache logs: "GET /media/css/base.css HTTP/1.1" 404 1185 "http://x.y.z.t/admin/" "Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0" x.y.z.t - - [19/Apr/2011:23:29:39 +0200] "GET /media/css/dashboard.css HTTP/1.1" 404 1189 "http://x.y.z.t/admin/" "Mozilla/5.0 (X11; Linux i686; rv:2.0) Gecko/20100101 Firefox/4.0" I will have a look at your link – philippe Apr 19 '11 at 21:33
0

I finally have solved this issue!

I have spend some time on it, looking on django book and stuff, but I discovered the solution at this link:

Solution_StackOverflow

This then gives my apache configuration file:

    Alias /media/css /data/media/css
<Directory /data/media/css>
    Order Allow,Deny
    Allow from all
</Directory>

<Directory />
    Options FollowSymlinks
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>

<Location /admin/>
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE accounts.settings
    PythonDebug On
    PythonPath "['/data/sites/accounts', '/data/sites/accounts/unix_accounts', '/data/sites', '/usr/lib/pymodules/python2.6/django'] + sys.path"
</Location>

I have copied media files at /data/media

I hope this could help someone having the same trouble.

Thanks a lot for your help!

Community
  • 1
  • 1
philippe
  • 2,949
  • 4
  • 20
  • 34