問題は静的ファイルの設定です。静的ファイルの設定
私は公式文書に従ってファイルを設定しました。
私が最初それから私はテンプレートにいくつかの変更を行っ
に私のURLリンクをアプリでstatic
というディレクトリを作成しました。
コードは以下の通りです:
settings.pyファイルで#Structure
src
|---makesite
|---sitemaker(app)
|---templates
| |----main.html
| |----static
| |-css
| |-style.css
|-static
|-manage.py
#The settings.py
STATIC_URL = '/static/'
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),]
STATIC_ROOT = os.path.join(BASE_DIR,"templates/static")
#The urls.py
from django.conf.urls import url
from django.contrib import admin
from makesite.views import make_site
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^main/',make_site),
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, documents_root=settings.STATIC_ROOT)
#The File structure
#The template
<!DOCTYPE html>
{% load staticfiles %}
<html>
<head>
<title>Main Site</title>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
<link rel= "{% static %}'css/style.css'" href="style.css">
あなたの 'STATICFILES_DIRS'設定は何ですか? 'DEBUG'が' True'の時、Djangoは 'STATICFILES_DIRS'が指し示すフォルダ内の静的ファイルを探します。 –
また、プロジェクトのディレクトリ構造を質問に追加できますか?その質問では、「** app **」に「静的」というディレクトリを作成しました。 ** static **ディレクトリは通常、ベースフォルダ内に作成されます。つまり、* manage.py *と一緒に作成されます。 –
それでも正しいことはありません。 – honesty1997