Python 呈现管理静态文件-DJANGO
我是Django新手,管理区域的css没有呈现。首先,我创建了一个加载了管理模块的应用程序,我就是这么做的: 通过将调试模式更改为false并添加数据库凭据来配置setting.py。然后:Python 呈现管理静态文件-DJANGO,python,django,macos,django-admin,Python,Django,Macos,Django Admin,我是Django新手,管理区域的css没有呈现。首先,我创建了一个加载了管理模块的应用程序,我就是这么做的: 通过将调试模式更改为false并添加数据库凭据来配置setting.py。然后: manage.py syncdb Creating tables ... Installing custom SQL ... Installing indexes ... Installed 0 object(s) from 0 fixture(s) - (……) 当我启动服务器时得到什么 Develo
manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
-
(……)
当我启动服务器时得到什么
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[09/Feb/2013 13:57:53] "GET /admin/ HTTP/1.1" 200 3270
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
Traceback (most recent call last):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
File "/Library/Python/2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
response = self.get_response(request)
response = self.get_response(request)
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 153, in get_response
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 153, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
return callback(request, **param_dict)
主页显示“出现服务器错误。请与管理员联系”。我可以访问该网站。com/admin/但不使用css。项目文件夹如下所示:
--project
----manage.py
----admin
-------css
-------img
-------js
----project
-------setting.py
-------urls.py
-------wsgi.py
-------__init__.py
首先,如果您正在运行开发服务器(使用
python manage.py runserver
),那么应该将DEBUG
设置为true。另外,您的STATIC\u ROOT
设置似乎还没有设置(或者设置为项目的根目录-这不是您在生产环境中运行应用程序时想要的)
在settings.py文件中,您需要确保django.contrib.staticfiles
包含在INSTALLED\u APPS
设置中。然后确保已经定义了静态URL(我认为它应该默认为/STATIC/
)。假设您在django的开发服务器上使用django 1.4,那么一切都应该正常工作,而不需要运行collectstatic
看看上面的文件。值得注意的是,在生产服务器上提供静态文件的过程是不同的
--project
----manage.py
----admin
-------css
-------img
-------js
----project
-------setting.py
-------urls.py
-------wsgi.py
-------__init__.py