【www.bbyears.com--python】
Django增加admin后台管理:
[root@hz Byrd]# python manage.py syncdb #建表、设置管理员
[root@hz Byrd]# cat Byrd/urls.py
urlpatterns = patterns("",
# Examples:
# url(r"^$", "{{ project_name }}.views.home", name="home"),
# url(r"^{{ project_name }}/", include("{{ project_name }}.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)), #将admin注释去掉
)
访问:http://mydomain/admin发现样式不正确,/static/admin/css/base.css这样的样式报404未找到错误!
继续测试:python manage.py runserver 0.0.0.0:8080 发现不经过nginx,样式是被加载的。
解决方法:
location /static/ {
alias /python目录/site-packages/django/contrib/admin/static/;
}