开发者

Problem on the management of django static file

I am using apache+mod_wsgi+django. I come across with this situation. I have a webpage shown in the browser but without the css style which ought to be there supposedly. Here is my configuration on the setting.py and apache_django_wsgi.conf.

setting py:

import os.path
import posixpath

PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_ROOT = ''
STATIC_URL = '/static/'

STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
'/Users/.../static',
'/Users/.../static',
'/Users/.../static',
'/var/Project/static',
)

STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
 #    'django.contrib.staticfiles.finders.DefaultStorageFinder',
 )

apache_django_wsgi:

Alias /static/ /var/Project/static/
<Directory /var/Project/static>
Order allow,deny
Options Indexes
Allow from all
IndexOptions FancyIndexing
</Directory>

so where do I do wrong?

And then when I try "python manage.py findstatic css/main.css" it returns me the error message like these:

Traceback (most recent call last):
File "manage.py", line 35, in <module>
execute_manager(settings)
File "/usr/local/lib64/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/usr/local/lib64/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib64/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib64/python2.6/site-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/usr/local/lib64/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib64/python2.6/site-packages/django/core/management/validation.py", line 103, in get_validation_errors
connection.validation.validate_field(e, opts, f)
File "/usr/local/lib64/python2.6/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field
db_version = self.connection.get_server_version()
File "/usr/local/lib64/python2.6/site-packages/django/db/backends/mysql/base.py", line 338, in get_server_version
self.cursor()
File "/usr/local/lib64/python2.6/site-packages/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/usr/local/lib64/python2.6/site-packages/django/db/backends/mysql/base.py", line 322, in _cursor
self.connection = Database.connect(**kwargs)
File "/usr/lib64/python2.6/site-packages/MySQLdb/__init__.py", line 71, in Connect
return Connection(*args, **kwargs)
File "/usr/lib64/python2.6/site-packages/MySQLdb/connections.py", line 170, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)")

Updates: Um..I think the path is right because when I check the error_log, I found that the server can locate the c开发者_运维问答ss/js. It just deny my access. The message is like these:

 client denied by server configuration: /var/Project/static/js/jquery.min.js, referer: http://<server>

So can anyone teach me how I can fix it? Does it have anything to do with the sql server?


Your traceback has nothing to do with static files. Check your DATABASE_* or DATABASES settings to match your environment. Check also if you mysql daemon is running (ps aux | grep mysql in ubuntu). After this traceback is gone, you have to do python manage.py collectstatic which will copy all your static files into one location Apache can serve it from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜