質問編集履歴

1

入力したコードを質問に記載しました。

2018/12/11 09:57

投稿

sunap220
sunap220

スコア19

test CHANGED
File without changes
test CHANGED
@@ -6,7 +6,11 @@
6
6
 
7
7
 
8
8
 
9
+ web_projプロジェクトの中にhelloアプリケーション作成を行っていました。
10
+
11
+
12
+
9
- ```Django
13
+ ```terminal
10
14
 
11
15
  Performing system checks...
12
16
 
@@ -87,3 +91,307 @@
87
91
  django.core.exceptions.ImproperlyConfigured: Specifying a namespace in include() without providing an app_name is not supported. Set the app_name attribute in the included module, or pass a 2-tuple containing the list of patterns and app_name instead.
88
92
 
89
93
  ```
94
+
95
+
96
+
97
+ web_proj/settings.py 以下
98
+
99
+
100
+
101
+ ```ここに言語を入力
102
+
103
+ import os
104
+
105
+
106
+
107
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
108
+
109
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
110
+
111
+
112
+
113
+
114
+
115
+ # Quick-start development settings - unsuitable for production
116
+
117
+ # See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/
118
+
119
+
120
+
121
+ # SECURITY WARNING: keep the secret key used in production secret!
122
+
123
+ SECRET_KEY = 'i72y3=nl%5fxh#(e-gi=+sq6$@ay6ot#b!_kyw=igsh18#5fu6'
124
+
125
+
126
+
127
+ # SECURITY WARNING: don't run with debug turned on in production!
128
+
129
+ DEBUG = True
130
+
131
+
132
+
133
+ ALLOWED_HOSTS = []
134
+
135
+
136
+
137
+
138
+
139
+ # Application definition
140
+
141
+
142
+
143
+ INSTALLED_APPS = [
144
+
145
+ 'django.contrib.admin',
146
+
147
+ 'django.contrib.auth',
148
+
149
+ 'django.contrib.contenttypes',
150
+
151
+ 'django.contrib.sessions',
152
+
153
+ 'django.contrib.messages',
154
+
155
+ 'django.contrib.staticfiles',
156
+
157
+ 'hello',
158
+
159
+ ]
160
+
161
+
162
+
163
+ MIDDLEWARE = [
164
+
165
+ 'django.middleware.security.SecurityMiddleware',
166
+
167
+ 'django.contrib.sessions.middleware.SessionMiddleware',
168
+
169
+ 'django.middleware.common.CommonMiddleware',
170
+
171
+ 'django.middleware.csrf.CsrfViewMiddleware',
172
+
173
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
174
+
175
+ 'django.contrib.messages.middleware.MessageMiddleware',
176
+
177
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
178
+
179
+ ]
180
+
181
+
182
+
183
+ ROOT_URLCONF = 'web_proj.urls'
184
+
185
+
186
+
187
+ TEMPLATES = [
188
+
189
+ {
190
+
191
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
192
+
193
+ 'DIRS': [],
194
+
195
+ 'APP_DIRS': True,
196
+
197
+ 'OPTIONS': {
198
+
199
+ 'context_processors': [
200
+
201
+ 'django.template.context_processors.debug',
202
+
203
+ 'django.template.context_processors.request',
204
+
205
+ 'django.contrib.auth.context_processors.auth',
206
+
207
+ 'django.contrib.messages.context_processors.messages',
208
+
209
+ ],
210
+
211
+ },
212
+
213
+ },
214
+
215
+ ]
216
+
217
+
218
+
219
+ WSGI_APPLICATION = 'web_proj.wsgi.application'
220
+
221
+
222
+
223
+
224
+
225
+ # Database
226
+
227
+ # https://docs.djangoproject.com/en/2.1/ref/settings/#databases
228
+
229
+
230
+
231
+ DATABASES = {
232
+
233
+ 'default': {
234
+
235
+ 'ENGINE': 'django.db.backends.sqlite3',
236
+
237
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
238
+
239
+ }
240
+
241
+ }
242
+
243
+
244
+
245
+
246
+
247
+ # Password validation
248
+
249
+ # https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators
250
+
251
+
252
+
253
+ AUTH_PASSWORD_VALIDATORS = [
254
+
255
+ {
256
+
257
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
258
+
259
+ },
260
+
261
+ {
262
+
263
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
264
+
265
+ },
266
+
267
+ {
268
+
269
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
270
+
271
+ },
272
+
273
+ {
274
+
275
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
276
+
277
+ },
278
+
279
+ ]
280
+
281
+
282
+
283
+
284
+
285
+ # Internationalization
286
+
287
+ # https://docs.djangoproject.com/en/2.1/topics/i18n/
288
+
289
+
290
+
291
+ LANGUAGE_CODE = 'ja'
292
+
293
+
294
+
295
+ TIME_ZONE = 'Asia/Tokyo'
296
+
297
+
298
+
299
+ USE_I18N = True
300
+
301
+
302
+
303
+ USE_L10N = True
304
+
305
+
306
+
307
+ USE_TZ = True
308
+
309
+
310
+
311
+
312
+
313
+ # Static files (CSS, JavaScript, Images)
314
+
315
+ # https://docs.djangoproject.com/en/2.1/howto/static-files/
316
+
317
+
318
+
319
+ STATIC_URL = '/static/'
320
+
321
+ ```
322
+
323
+
324
+
325
+ hello/views.py 以下
326
+
327
+
328
+
329
+ ```ここに言語を入力
330
+
331
+ from django.http.response import HttpResponse
332
+
333
+
334
+
335
+ # Create your views here.
336
+
337
+
338
+
339
+
340
+
341
+ def hello_world(request):
342
+
343
+ return HttpResponse('Hello World!')
344
+
345
+
346
+
347
+
348
+
349
+ ```
350
+
351
+
352
+
353
+ hello/urls.py 以下
354
+
355
+
356
+
357
+ ```ここに言語を入力
358
+
359
+ from django.conf.urls import url
360
+
361
+ from . import views
362
+
363
+
364
+
365
+
366
+
367
+ urlpatterns = [
368
+
369
+ url(r'^$', views.hello_world, name = 'hello_world'),
370
+
371
+ ]
372
+
373
+ ```
374
+
375
+
376
+
377
+ web_proj/urls.py 以下
378
+
379
+
380
+
381
+ ```ここに言語を入力
382
+
383
+ from django.conf.urls import include, url
384
+
385
+
386
+
387
+
388
+
389
+ urlpatterns = [
390
+
391
+ url(r'^hello/', include('hello.urls', namespace='hello')),
392
+
393
+ ]
394
+
395
+
396
+
397
+ ```