J'utilise apache + mod_wsgi + django. Je rencontre avec cette situation. J'ai une page Web montrée dans le navigateur mais sans le style de css qui devrait être là censément. Voici ma configuration sur le setting.py et apache_django_wsgi.conf.Problème sur la gestion du fichier statique django
mise 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>
alors où dois-je faire de mal?
Et puis quand j'essaye "python manage.py findstatic css/main.css" il me renvoie le message d'erreur comme ceux-ci:
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)")
Mises à jour: Um..I pense que le chemin est droit parce que quand Je vérifie le error_log, j'ai trouvé que le serveur peut localiser le css/js. Cela nie simplement mon accès. Le message est comme ceux-ci:
client denied by server configuration: /var/Project/static/js/jquery.min.js, referer: http://<server>
Donc, quelqu'un peut-il m'apprendre comment je peux le réparer? Cela a-t-il quelque chose à voir avec le serveur sql?
Votre connexion mysql est mal configurée. Testez d'abord votre connexion mysql. –
Cela ne peut pas être votre configuration Apache, sinon vous l'avez vraiment bourré. Où se trouve l'ouverture correspondant à la fermeture . Inclure la configuration appropriée et ne pas éditer les bits. –