1

I am trying to deploy my Django project using mod_wsgi and Apache2 but I am not able to figure out why the admin CSS styles aren't loading. I have used Django-admin-tools as an App to enhance the looks of admin interface and its working pretty well on the development server but the styles problem has occurred during deployment.

Project Path on server is :

'/srv/www/myapp/'
'/srv/www/myapp/media/admin_tools/css|js|images'

setting.py contains:

MEDIA_ROOT = '/srv/www/myapp/media/' 
# also tried MEDIA_ROOT = '/srv/www/myapp/media/admin_tools/'

MEDIA_URL = 'http://myserverip:80/media/'
STATIC_ROOT = '/srv/www/myapp/static'
STATIC_URL = '/static/'
ADMIN_MEDIA_PREFIX = '/media/'  
# also tried ADMIN_MEDIA_PREFIX = '/media/admin_tools/'

STATICFILES_DIRS = (
'/srv/www/myapp/projectstatic' )

TEMPLATE_DIRS = (
'/srv/www/myapp/templates' )

INSTALLED_APPS = (
'admin_tools',
'admin_tools.theming',
'admin_tools.menu',
'admin_tools.dashboard',
'django.contrib.auth',
#Many other applications )

ADMIN_TOOLS_INDEX_DASHBOARD = 'myapp.dashboard.CustomIndexDashboard'
ADMIN_TOOLS_APP_INDEX_DASHBOARD = 'myapp.dashboard.CustomAppIndexDashboard'
ADMIN_TOOLS_THEMING_CSS = '/srv/www/myapp/media/admin_tools/css/theming.css'
ADMIN_TOOLS_MENU = 'myapp.menu.CustomMenu'

urls.py:

urlpatterns = patterns('',
url(r'^admin_tools/', include('admin_tools.urls')),
)

django.wsgi: (the path of this file is '/srv/www/myapp/apache/django.wsgi')

import os
import sys

path = '/srv/www/'

if path not in sys.path:
    sys.path.insert(0, '/srv/www/')

sys.path = ['/srv/www/myapp'] + sys.path
sys.path.append('/usr/local/lib/python2.7/dist-packages/registration/backends')
os.environ['DJANGO_SETTINGS_MODULE'] = 'myapp.settings'
print >> sys.stderr, sys.path

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Ali Raza Bhayani
  • 3,045
  • 26
  • 20

1 Answers1

0

in the directory '/srv/www/myapp/apache/' you may want to create another conf file. For this example I would use apache_django_wsgi.conf. In that file take all the contents in in /etc/apache2/httpd.conf and copy to apache_django_wsgi.conf and replace it with

LoadModule wsgi_module modules/mod_wsgi.so
include "/srv/www/myapp/apache/apache_django_apache.conf"

Now to serve admin files: in apache_django_apache.conf add and alias for your admin files: example

Alias /admin_media/ /path/to/admin_media
<Directory "admin_media">
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>
Frantz Romain
  • 836
  • 1
  • 6
  • 14
  • 1
    I followed your instructions and I also re-implemented the deployment tutorial of django docs , https://code.djangoproject.com/wiki/django_apache_and_mod_wsgi, but still the styles are not loading.. Anyone else experienced similar problems while dealing with django-admin-tools. – Ali Raza Bhayani Apr 16 '12 at 11:02
  • I know this is an old comment but did you ever get it working? I seem to have the same issue now. – abarax Mar 17 '14 at 11:44