0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

PythonAnywhereでCSSが効かない

Last updated at Posted at 2024-01-10

PythonAnywareを用いた時にCSSが効かない問題を解決

PythonAnywhereで参照しているstaticと自分が作成したstaticのpathが違うことによる問題

setting.py で

qiita.python.Django
STATIC_URL = 'static'

STATICFILES_DIRS = (
    [
        os.path.join(BASE_DIR, "<app-name>/static/css/"), 
    ]
)

となっていることを確認

webページの検証ツールで現在参照しているlinkを確認(headerに書いてあるはず)

cssのあるstaticのパスをPythonAnewhereのWebのstaticのDirectoryに書き込む
これがもともとhomeディレクトリにあるのが原因だと思われる

qiita.bash
$  python manage.py collectstatic 

を実行

あとはリロードすればいけるはず

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?