1

I deployed my Django project on Apache but when I navigate to the admin page, it doesn't seem to have the same formatting as the test server that is included with Django. I have tinkered around with the configurations and soft links quite a bit but have had no success thus far. I'm hoping that someone more experienced than me in Django and Apache can spot check my issue and diagnose the problem. Find below the steps I took while installing Django as well as the contents of the configuration files.

installation process

svn co http://code.djangoproject.com/svn/django/trunk/ /usr/share/django
chown -R www-data:www-data /usr/share/django
ln -s /usr/share/django/django /usr/lib/python2.6/dist-packages/django
ln -s /usr/share/django/django/bin/django-admin.py /usr/local/bin/django-admin.py
mkdir /var/www/mydjango/django_projects
mkdir /var/www/mydjango/django_templates
mkdir /var/www/mydjango/media
ln -s /usr/share/django/django/contrib/admin/media /var/www/mydjango/admin_media
django-admin.py startproject /var/www/mydjango/django_projects/mydjango
/var/www/mydjango/django_projects/mydjango/manage.py collectstatic --noinput
(I've added the static files generated to 
/usr/share/django/django/contrib/admin/media since it was empty)

settings.py

MEDIA_ROOT = '/var/www/mydjango/media/admin/' 
(I've also tried '/var/www/mydjango/media/')
MEDIA_URL = 'http://mydjango.mydomain.com/media/admin/'
STATIC_ROOT = ''
STATIC_URL = '/static/'

http.conf

Alias /admin_media/ /var/www/mydjango/admin_media/
Alias /media/ /var/www/mydjango/media/

<Directory "/admin_media/">
Order deny,allow
Allow from all
</Directory>

<Directory "/media/">
Order deny,allow
Allow from all
</Directory>

WSGIScriptAlias / /var/www/apache/django.wsgi
<Directory /var/www/apache/>
Order deny,allow
Allow from all
</Directory>

django.wsgi

import os
import sys

path = '/var/www/mydjango/django_projects/mydjango'
if path not in sys.path:
    sys.path.append(path)

os.environ['DJANGO_SETTINGS_MODULE'] = 'mydjango.settings'

import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
4

1 回答 1

0

Moderna Django 版本不在 MEDIA_URL 中查找管理内容。使用collectstatic

于 2012-04-22T06:47:40.423 回答