下面本文给各位介绍linux下Nginx+Django Admin界面无样式问题解决方法,如果你碰到此问题可以一起来看看吧.
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: --phpfensi.com
# 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/;
}。
大型站长资讯类网站! https://www.nzzz.com.cn