我只安装了apache和django。
django 默认页面工作正常:
但/admin/站点不是:
Apache conf (/etc/init.d/apache2/sites-avaliable/mysite.conf) 文件:
<VirtualHost *:80>
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
ServerName mysite.com.br
Alias /static /var/www/mysite/media/static/
<Directory /var/www/mysite/mysite>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
wsgi 文件(/var/www/mysite/mysite/wsgi.py):
import os
import sys
sys.path.insert(0, '/var/www/mysite')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
Django mysite.settings (/var/www/mysite/mysite/settings.py):
...
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
...
Django mysite.urls (/var/www/mysite/mysite/urls.py):
from django.conf.urls import patterns, include, url
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
就这样。我错过了什么吗?
谢谢!
最佳答案
这是 apache 配置错误。
我相信你应该指的是:-
<Directory /var/www/mysite>
Order allow,deny
Allow from all
</Directory>
关于在/admin/中找不到 Django 管理页面,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13637922/