質問編集履歴

2

settings\.py追記

2017/01/26 10:10

投稿

PYPP
PYPP

スコア51

test CHANGED
File without changes
test CHANGED
@@ -138,7 +138,11 @@
138
138
 
139
139
  'BACKEND': 'django.template.backends.django.DjangoTemplates',
140
140
 
141
- 'DIRS': [],
141
+ 'DIRS': [
142
+
143
+ os.path.join(BASE_DIR, 'templates'),
144
+
145
+ ],
142
146
 
143
147
  'APP_DIRS': True,
144
148
 

1

top\.html、settings\.pyを追記。

2017/01/26 10:10

投稿

PYPP
PYPP

スコア51

test CHANGED
File without changes
test CHANGED
@@ -36,6 +36,234 @@
36
36
 
37
37
 
38
38
 
39
+ top.html
40
+
41
+ ```
42
+
43
+ <!DOCTYPE html>
44
+
45
+ <html>
46
+
47
+ <head lang="ja">
48
+
49
+ <meta charset="UTF-8">
50
+
51
+ <title></title>
52
+
53
+ </head>
54
+
55
+ <body>
56
+
57
+ Hello Template!
58
+
59
+ </body>
60
+
61
+ </html>
62
+
63
+ ```
64
+
65
+
66
+
67
+ settings.py
68
+
69
+ ```
70
+
71
+ import os
72
+
73
+
74
+
75
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
76
+
77
+
78
+
79
+ SECRET_KEY = ???
80
+
81
+
82
+
83
+ DEBUG = True
84
+
85
+
86
+
87
+ ALLOWED_HOSTS = []
88
+
89
+
90
+
91
+ INSTALLED_APPS = [
92
+
93
+ 'django.contrib.admin',
94
+
95
+ 'django.contrib.auth',
96
+
97
+ 'django.contrib.contenttypes',
98
+
99
+ 'django.contrib.sessions',
100
+
101
+ 'django.contrib.messages',
102
+
103
+ 'django.contrib.staticfiles',
104
+
105
+ 'posts',
106
+
107
+ ]
108
+
109
+
110
+
111
+ MIDDLEWARE = [
112
+
113
+ 'django.middleware.security.SecurityMiddleware',
114
+
115
+ 'django.contrib.sessions.middleware.SessionMiddleware',
116
+
117
+ 'django.middleware.common.CommonMiddleware',
118
+
119
+ 'django.middleware.csrf.CsrfViewMiddleware',
120
+
121
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
122
+
123
+ 'django.contrib.messages.middleware.MessageMiddleware',
124
+
125
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
126
+
127
+ ]
128
+
129
+
130
+
131
+ ROOT_URLCONF = 'mysite.urls'
132
+
133
+
134
+
135
+ TEMPLATES = [
136
+
137
+ {
138
+
139
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
140
+
141
+ 'DIRS': [],
142
+
143
+ 'APP_DIRS': True,
144
+
145
+ 'OPTIONS': {
146
+
147
+ 'context_processors': [
148
+
149
+ 'django.template.context_processors.debug',
150
+
151
+ 'django.template.context_processors.request',
152
+
153
+ 'django.contrib.auth.context_processors.auth',
154
+
155
+ 'django.contrib.messages.context_processors.messages',
156
+
157
+ ],
158
+
159
+ },
160
+
161
+ },
162
+
163
+ ]
164
+
165
+
166
+
167
+ WSGI_APPLICATION = 'mysite.wsgi.application'
168
+
169
+
170
+
171
+ TEMPLATES_DIRS = {
172
+
173
+ STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'media', 'templates')
174
+
175
+ }
176
+
177
+
178
+
179
+ DATABASES = {
180
+
181
+ 'default': {
182
+
183
+ 'ENGINE': 'django.db.backends.sqlite3',
184
+
185
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
186
+
187
+ }
188
+
189
+ }
190
+
191
+
192
+
193
+ AUTH_PASSWORD_VALIDATORS = [
194
+
195
+ {
196
+
197
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
198
+
199
+ },
200
+
201
+ {
202
+
203
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
204
+
205
+ },
206
+
207
+ {
208
+
209
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
210
+
211
+ },
212
+
213
+ {
214
+
215
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
216
+
217
+ },
218
+
219
+ ]
220
+
221
+
222
+
223
+ LANGUAGE_CODE = 'en-us'
224
+
225
+
226
+
227
+ TIME_ZONE = 'UTC'
228
+
229
+
230
+
231
+ USE_I18N = True
232
+
233
+
234
+
235
+ USE_L10N = True
236
+
237
+
238
+
239
+ USE_TZ = True
240
+
241
+
242
+
243
+ MEDIA_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'media')
244
+
245
+ MEDIA_URL = '/media/'
246
+
247
+
248
+
249
+ # Static files (CSS, JavaScript, Images)
250
+
251
+ # https://docs.djangoproject.com/en/1.10/howto/static-files/
252
+
253
+ STATIC_ROOT = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'static-only')
254
+
255
+
256
+
257
+ STATIC_URL = '/static/'
258
+
259
+ STATICFILES_DIRS = {
260
+
261
+ os.path.join(os.path.dirname(os.path.dirname(__file__)), 'static', 'static'),
262
+
263
+ }
264
+
265
+ ```
266
+
39
267
  ###試したこと
40
268
 
41
269
  エラーの度に、スタックオーバーフローなどを参照したのですが、なかなか解決できませんでした。