他のスタックのソリューションをフォローしようとしましたが、Django静的ファイルを本番環境で提供していましたが、動作させることができませんでした。私の静的ファイルは私のdjango appフォルダ(リーグ)の中にあります。静的ファイルを提供するdjango 1.9 productionエラー
私のCSSファイルが正しく読み込まれていません。私はクロームで、コンソールに次のエラーを得た:
Resource interpreted as Stylesheet but transferred with MIME type text/html
Uncaught SyntaxError: Unexpected token !
profile:5 Uncaught SyntaxError: Unexpected token !
私はCSSファイルをHTMLファイルとして解釈されていることと思いますか? javacriptファイルが正しく読み込まれていないと思います...
クロムのソースファイルをチェックして、cssファイルへのリンクをクリックしたときに機能しません。だから私は、CSSファイルへのリンクが動作しないと推測している?
リンクやスクリプト、CSSをロードするとJavaScriptファイルは、次のとおりです。次のように私のsettings.pyファイルに
<head>
<!-- Latest compiled and minified CSS -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<link rel="stylesheet" href="{% static 'league/css/bootstrap-theme.css' %}">
<link rel="stylesheet" href="{% static 'league/css/bootstrap-theme.min.css' %}">
<link rel="stylesheet" href="{% static 'league/css/bootstrap.css' %}">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script type="text/javascript" src="{% static 'league/js/bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'league/js/npm.js' %}"></script>
<!-- jQuery library -->
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="{% static 'league/css/f-style.css' %}">
</head>
私の関連ファイルは、次のとおりです。
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
STATIC_URL = '/league/static/'
SITE_ID = 1
STATIC_ROOT = BASE_DIR + '/league/static/'
私の上の設定ファイルApacheサーバーは次のとおりです。
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
Alias /static /home/ubunu/project/league/static
<Directory /home/ubuntu/project/league/static>
Require all granted
</Directory>
<Directory /home/ubuntu/project/fantasy>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
WSGIDaemonProcess project python-path=/home/ubuntu/project:/home/ubuntu/project/myprojectenv/lib/python2.7/$
WSGIProcessGroup project
WSGIScriptAlias//home/ubuntu/project/fantasy/wsgi.py
</VirtualHost>
ありがとうございます!
サーバーにサーバーを再起動してみました。またテンプレートで{%load staticfiles%}タグを使用していません。 –