質問編集履歴

1

追記

2020/05/09 10:51

投稿

sorara
sorara

スコア17

test CHANGED
File without changes
test CHANGED
@@ -7,3 +7,355 @@
7
7
  それで、runserverにつながることができません。
8
8
 
9
9
  どなたか、教えていただけないでしょうか?
10
+
11
+ いじったのは下記のものたちです。
12
+
13
+ models.pyです↓
14
+
15
+ ```ここに言語を入力
16
+
17
+ from django.db import models
18
+
19
+
20
+
21
+ # Create your models here.
22
+
23
+ class Blog(models.Model):
24
+
25
+ #id=1,2,,4,
26
+
27
+ content=models.CharField(max_length=140)
28
+
29
+ posted_date=models.DateTimeField(auto_now_add=True)
30
+
31
+ ```
32
+
33
+ views.pyです↓
34
+
35
+ ```ここに言語を入力
36
+
37
+ from django.shortcuts import rende
38
+
39
+ from django.views.generic import ListView
40
+
41
+ from .models import Blog
42
+
43
+
44
+
45
+ class BlogListView(ListView):
46
+
47
+ model=Blog
48
+
49
+
50
+
51
+ ```
52
+
53
+ templetes/blog_list.htmlです↓
54
+
55
+ ```ここに言語を入力
56
+
57
+ <h1>Bolg_LIST</h1>
58
+
59
+ ```
60
+
61
+ urls.pyです↓
62
+
63
+ ```ここに言語を入力
64
+
65
+ """microblog URL Configuration
66
+
67
+
68
+
69
+ The `urlpatterns` list routes URLs to views. For more information please see:
70
+
71
+ https://docs.djangoproject.com/en/3.0/topics/http/urls/
72
+
73
+ Examples:
74
+
75
+ Function views
76
+
77
+ 1. Add an import: from my_app import views
78
+
79
+ 2. Add a URL to urlpatterns: path('', views.home, name='home')
80
+
81
+ Class-based views
82
+
83
+ 1. Add an import: from other_app.views import Home
84
+
85
+ 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
86
+
87
+ Including another URLconf
88
+
89
+ 1. Import the include() function: from django.urls import include, path
90
+
91
+ 2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
92
+
93
+
94
+
95
+ """
96
+
97
+ from django.contrib import admin
98
+
99
+ from django.urls import path
100
+
101
+ from blog.views import BlogListView
102
+
103
+
104
+
105
+ urlpatterns = [
106
+
107
+ path('',BlogListView.as_view(),name="index"),
108
+
109
+ path('admin/', admin.site.urls),
110
+
111
+ ]
112
+
113
+ ```
114
+
115
+ settings.pyです↓
116
+
117
+ ```ここに言語を入力
118
+
119
+ """
120
+
121
+ Django settings for microblog project.
122
+
123
+
124
+
125
+ Generated by 'django-admin startproject' using Django 3.0.6.
126
+
127
+
128
+
129
+ For more information on this file, see
130
+
131
+ https://docs.djangoproject.com/en/3.0/topics/settings/
132
+
133
+
134
+
135
+ For the full list of settings and their values, see
136
+
137
+ https://docs.djangoproject.com/en/3.0/ref/settings/
138
+
139
+ """
140
+
141
+
142
+
143
+ import os
144
+
145
+
146
+
147
+ # Build paths inside the project like this: os.path.join(BASE_DIR, ...)
148
+
149
+ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
150
+
151
+
152
+
153
+
154
+
155
+ # Quick-start development settings - unsuitable for production
156
+
157
+ # See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
158
+
159
+
160
+
161
+ # SECURITY WARNING: keep the secret key used in production secret!
162
+
163
+ SECRET_KEY = 'c01ks6_7xn*u!^1^++*a+l!165=(hzbramszzju=8628er0dko'
164
+
165
+
166
+
167
+ # SECURITY WARNING: don't run with debug turned on in production!
168
+
169
+ DEBUG = True
170
+
171
+
172
+
173
+ ALLOWED_HOSTS = []
174
+
175
+
176
+
177
+
178
+
179
+ # Application definition
180
+
181
+
182
+
183
+ INSTALLED_APPS = [
184
+
185
+ 'django.contrib.admin',
186
+
187
+ 'django.contrib.auth',
188
+
189
+ 'django.contrib.contenttypes',
190
+
191
+ 'django.contrib.sessions',
192
+
193
+ 'django.contrib.messages',
194
+
195
+ 'django.contrib.staticfiles',
196
+
197
+ 'blog',
198
+
199
+ ]
200
+
201
+
202
+
203
+ MIDDLEWARE = [
204
+
205
+ 'django.middleware.security.SecurityMiddleware',
206
+
207
+ 'django.contrib.sessions.middleware.SessionMiddleware',
208
+
209
+ 'django.middleware.common.CommonMiddleware',
210
+
211
+ 'django.middleware.csrf.CsrfViewMiddleware',
212
+
213
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
214
+
215
+ 'django.contrib.messages.middleware.MessageMiddleware',
216
+
217
+ 'django.middleware.clickjacking.XFrameOptionsMiddleware',
218
+
219
+ ]
220
+
221
+
222
+
223
+ ROOT_URLCONF = 'microblog.urls'
224
+
225
+
226
+
227
+ TEMPLATES = [
228
+
229
+ {
230
+
231
+ 'BACKEND': 'django.template.backends.django.DjangoTemplates',
232
+
233
+ 'DIRS': [],
234
+
235
+ 'APP_DIRS': True,
236
+
237
+ 'OPTIONS': {
238
+
239
+ 'context_processors': [
240
+
241
+ 'django.template.context_processors.debug',
242
+
243
+ 'django.template.context_processors.request',
244
+
245
+ 'django.contrib.auth.context_processors.auth',
246
+
247
+ 'django.contrib.messages.context_processors.messages',
248
+
249
+ ],
250
+
251
+ },
252
+
253
+ },
254
+
255
+ ]
256
+
257
+
258
+
259
+ WSGI_APPLICATION = 'microblog.wsgi.application'
260
+
261
+
262
+
263
+
264
+
265
+ # Database
266
+
267
+ # https://docs.djangoproject.com/en/3.0/ref/settings/#databases
268
+
269
+
270
+
271
+ DATABASES = {
272
+
273
+ 'default': {
274
+
275
+ 'ENGINE': 'django.db.backends.sqlite3',
276
+
277
+ 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
278
+
279
+ }
280
+
281
+ }
282
+
283
+
284
+
285
+
286
+
287
+ # Password validation
288
+
289
+ # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
290
+
291
+
292
+
293
+ AUTH_PASSWORD_VALIDATORS = [
294
+
295
+ {
296
+
297
+ 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
298
+
299
+ },
300
+
301
+ {
302
+
303
+ 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
304
+
305
+ },
306
+
307
+ {
308
+
309
+ 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
310
+
311
+ },
312
+
313
+ {
314
+
315
+ 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
316
+
317
+ },
318
+
319
+ ]
320
+
321
+
322
+
323
+
324
+
325
+ # Internationalization
326
+
327
+ # https://docs.djangoproject.com/en/3.0/topics/i18n/
328
+
329
+
330
+
331
+ LANGUAGE_CODE = 'ja'
332
+
333
+
334
+
335
+ TIME_ZONE = 'UTC'
336
+
337
+
338
+
339
+ USE_I18N = True
340
+
341
+
342
+
343
+ USE_L10N = True
344
+
345
+
346
+
347
+ USE_TZ = True
348
+
349
+
350
+
351
+
352
+
353
+ # Static files (CSS, JavaScript, Images)
354
+
355
+ # https://docs.djangoproject.com/en/3.0/howto/static-files/
356
+
357
+
358
+
359
+ STATIC_URL = '/static/'
360
+
361
+ ```