0

わかりましたので、settings.py に変更を加えていません。css で使用したい画像はこちらです。

C:\djcode\testapp1\testing1\testingapp1\static\testingapp1\images

私のstyle.cssファイルはここにあります。

C:\djcode\testapp1\testing1\testingapp1\static\testingapp1

私のmanage.pyファイルはここにあります。

C:\djcode\testapp1\testing1

私のsettings.pyファイルはここにあります。

C:\djcode\testapp1\testing1\testing1

私のテンプレート (index.html を含む) はこちらです。

C:\djcode\testapp1\testing1\testingapp1\templates

私の index.html ファイルでは、index.html ファイルの先頭にこれを入力して css をリンクしました。

{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'testingapp1/style.css' %}" />

これを行うことで、cssファイルの画像を使用してみました。

background: url(images/picture.png);

私も試しました。

background: url({% static 'testingapp1/images/picture.png' %})

しかし、それもうまくいきませんでした。何が間違っているのですか?

4

1 に答える 1