下面本文给各位介绍linux下Nginx+Django Admin界面无样式问题解决方法,如果你碰到此问题可以一起来看看吧.
Django增加admin后台管理:
- [root@hzByrd]#pythonmanage.pysyncdb#建表、设置管理员
- [root@hzByrd]#catByrd/urls.py
- urlpatterns=patterns('',
- #Examples:
- #url(r'^$','{{project_name}}.views.home',name='home'),
- #url(r'^{{project_name}}/',include('{{project_name}}.foo.urls')),
- #Uncommenttheadmin/doclinebelowtoenableadmindocumentation:--phpfensi.com
- #url(r'^admin/doc/',include('django.contrib.admindocs.urls')),
- #Uncommentthenextlinetoenabletheadmin:
- 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/;
- }