octopusgrabbus
octopusgrabbus

Reputation: 10695

Getting Django Admin Site Formatted Under Apache

My question is how can I get my Django admin site to be formatted (all pretty) under Apache the way it is under runserver? I can bring it up and log into it, but it is not all nicely formatted.

There is nothing special about my urls.py file

from django.conf.urls.defaults import *
from django.contrib import admin
from amr.views import hello

admin.autodiscover()

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
    ('^hello/$', hello),
    # Example:
    # (r'^amr/', include('amr.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # (r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    (r'^admin/', include(admin.site.urls)),
)

Here's my apache config.

<Location />
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE settings
        PythonOption django.root /home/amr/django/amr
        PythonPath "['/home/amr/django', '/home/amr/django/amr', '/usr/local/lib
/site-packages/django'] + sys.path"
        PythonDebug On
</Location>

Upvotes: 1

Views: 745

Answers (1)

Dave Forgac
Dave Forgac

Reputation: 3326

You're likely missing the CSS/JS for ADMIN_MEDIA. This setting is in the settings.py. I usually set it to:

ADMIN_MEDIA_PREFIX = '/adminmedia/'

I then add the following to my Apache conf (modify for your actual path):

Alias /adminmedia /usr/lib/python2.6/site-packages/django/contrib/admin/media/

This serves the default Django admin media files.

You can then override the admin templates as described here:

http://docs.djangoproject.com/en/dev/ref/contrib/admin/#overriding-admin-templates

Upvotes: 1

Related Questions