2010-09-24 33 views
1

我的問題是如何讓我的Django管理站點被格式化(所有漂亮)在Apache下的方式是在runserver下?我可以將其啓動並登錄到它,但它並非全部格式良好。獲取Django管理站點格式化在Apache下

沒有什麼特別之處我的urls.py文件

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)), 
) 

這裏是我的Apache配置。

<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> 

回答

1

您很可能缺少ADMIN_MEDIA的CSS/JS。該設置位於settings.py。我通常把它設置爲:

ADMIN_MEDIA_PREFIX = '/adminmedia/'

我然後添加以下到我的Apache配置(修改您的實際路徑):

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

這成爲默認的admin界面的媒體文件。

然後,您可以覆蓋管理模板如下所述:

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