質問編集履歴
4
8
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
index.html no2.htmlを
|
1
|
+
index.html no2.htmlを表示させたい
|
test
CHANGED
@@ -1,17 +1,3 @@
|
|
1
|
-
お世話になります。
|
2
|
-
|
3
|
-
http://hoge.com/templates/index.html
|
4
|
-
|
5
|
-
http://hoge.com/templates/no2.htmlというURLをdjango上で表示させたいです。django1週間目です。
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
プロジェクト名:project
|
10
|
-
|
11
|
-
アプリケーション名:app
|
12
|
-
|
13
|
-
|
14
|
-
|
15
1
|
#やりたいこと
|
16
2
|
|
17
3
|
hoge.com/templates/index.html hoge.com/templates/no2.htmlというURLで表示させたい。
|
@@ -65,11 +51,3 @@
|
|
65
51
|
|
66
52
|
|
67
53
|
```
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
sysctl、migrate、runserverは実施済です。
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
宜しくお願いします。
|
3
8
test
CHANGED
File without changes
|
test
CHANGED
@@ -44,97 +44,7 @@
|
|
44
44
|
|
45
45
|
|
46
46
|
|
47
|
-
```
|
48
|
-
|
49
|
-
#エラー no2.html
|
50
|
-
|
51
|
-
```ここに言語を入力
|
52
|
-
|
53
|
-
Page not found (404)
|
54
|
-
|
55
|
-
Request Method: GET
|
56
|
-
|
57
|
-
Request URL: http://xxx.xxx/templates/no2.html
|
58
|
-
|
59
|
-
Using the URLconf defined in project.urls, Django tried these URL patterns, in this order:
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
admin/
|
64
|
-
|
65
|
-
[name='index']
|
66
|
-
|
67
|
-
The current path, templates/no2.html, didn't match any of these.
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
|
72
|
-
|
73
|
-
admin/
|
74
|
-
|
75
|
-
[name='index']
|
76
|
-
|
77
|
-
The current path, no2.html, didn't match any of these.
|
78
|
-
|
79
|
-
```
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
エラーをみると、プロジェクトのurls.pyの中のurlと
|
84
|
-
|
85
|
-
templates/no2.html
|
86
|
-
|
87
|
-
templates/index.html
|
88
|
-
|
89
|
-
が合致していないという内容は理解したのですが、プロジェクト内のurls.pyの指定方法がわかりません。
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
サーバと独自ドメインはhoge.comをすでに用意しその中にdjangoを入れています。ロケットは既に見えてます。
|
96
|
-
|
97
|
-
webサーバはnginxを立ててます。以下のようなディレクトリ構成です。変更作成したファイルは5つです。
|
98
|
-
|
99
|
-
```ここに言語を入力
|
100
|
-
|
101
|
-
home
|
102
|
-
|
103
|
-
-djangouser
|
104
|
-
|
105
|
-
-hoge.com
|
106
|
-
|
107
|
-
|
47
|
+
#urls.py
|
108
|
-
|
109
|
-
-project
|
110
|
-
|
111
|
-
-urls.py➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回修正--1
|
112
|
-
|
113
|
-
-app 変更なし
|
114
|
-
|
115
|
-
-static_sites
|
116
|
-
|
117
|
-
-urls.py➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--2
|
118
|
-
|
119
|
-
-views.py➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--3
|
120
|
-
|
121
|
-
-templates
|
122
|
-
|
123
|
-
-index.html➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--4
|
124
|
-
|
125
|
-
-no2.html➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--5
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
```
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
上記の5ファイルについて作成・追記を行いましたがsysctlやcollectstaticやrunserverを実施してもhtmlが見れません。
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
#urls.py➡プロジェクト➡➡➡➡➡➡今回修正--1
|
138
48
|
|
139
49
|
```
|
140
50
|
|
@@ -158,141 +68,7 @@
|
|
158
68
|
|
159
69
|
|
160
70
|
|
161
|
-
#-urls.py➡static_sites➡➡➡➡➡➡今回追加--2
|
162
|
-
|
163
|
-
```
|
164
|
-
|
165
|
-
from django.urls import path
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
from . import views
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
urlpatterns = [
|
174
|
-
|
175
|
-
path('', views.index, name='index'),
|
176
|
-
|
177
|
-
path('index', views.show_index, name='show_index'),
|
178
|
-
|
179
|
-
path('no2', views.show_no2, name='show_no2'),
|
180
|
-
|
181
|
-
]
|
182
|
-
|
183
|
-
```
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
#views.py➡static_sites➡➡➡➡➡➡今回追加--3
|
188
|
-
|
189
|
-
```
|
190
|
-
|
191
|
-
from django.shortcuts import render
|
192
|
-
|
193
|
-
from django.http import HttpResponse
|
194
|
-
|
195
|
-
from django.shortcuts import render
|
196
|
-
|
197
|
-
# Create your views here.
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
def index(request):
|
204
|
-
|
205
|
-
return HttpResponse("Hello")
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
def show_index(request):
|
212
|
-
|
213
|
-
return render(request, 'index.html')
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
def show_no2(request):
|
220
|
-
|
221
|
-
return render(request, 'no2.html')
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
```
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
#-index.html➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--4
|
230
|
-
|
231
|
-
```
|
232
|
-
|
233
|
-
<!DOCTYPE html>
|
234
|
-
|
235
|
-
<html lang="en">
|
236
|
-
|
237
|
-
<head>
|
238
|
-
|
239
|
-
<meta charset="UTF-8">
|
240
|
-
|
241
|
-
<title>Title</title>
|
242
|
-
|
243
|
-
</head>
|
244
|
-
|
245
|
-
<body>
|
246
|
-
|
247
|
-
index.html hogegegegegegegegegegegegegegegge
|
248
|
-
|
249
|
-
</body>
|
250
|
-
|
251
|
-
</html>
|
252
|
-
|
253
|
-
```
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
#-no2.html➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡➡今回追加--5
|
258
|
-
|
259
|
-
```
|
260
|
-
|
261
|
-
<!DOCTYPE html>
|
262
|
-
|
263
|
-
<html lang="en">
|
264
|
-
|
265
|
-
<head>
|
266
|
-
|
267
|
-
<meta charset="UTF-8">
|
268
|
-
|
269
|
-
<title>Title</title>
|
270
|
-
|
271
|
-
</head>
|
272
|
-
|
273
|
-
<body>
|
274
|
-
|
275
|
-
no2.html hogeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
|
276
|
-
|
277
|
-
</body>
|
278
|
-
|
279
|
-
</html>
|
280
|
-
|
281
|
-
```
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
#ためしたこと
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
上記全て記載しtemplatesフォルダの中に2つのhtmlファイルを格納し
|
290
|
-
|
291
|
-
http://hoge.com/templates/index.html
|
292
|
-
|
293
|
-
http://hoge.com/templates/no2.html
|
294
|
-
|
295
|
-
|
71
|
+
sysctl、migrate、runserverは実施済です。
|
296
72
|
|
297
73
|
|
298
74
|
|
2
8
test
CHANGED
File without changes
|
test
CHANGED
@@ -80,6 +80,18 @@
|
|
80
80
|
|
81
81
|
|
82
82
|
|
83
|
+
エラーをみると、プロジェクトのurls.pyの中のurlと
|
84
|
+
|
85
|
+
templates/no2.html
|
86
|
+
|
87
|
+
templates/index.html
|
88
|
+
|
89
|
+
が合致していないという内容は理解したのですが、プロジェクト内のurls.pyの指定方法がわかりません。
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
83
95
|
サーバと独自ドメインはhoge.comをすでに用意しその中にdjangoを入れています。ロケットは既に見えてます。
|
84
96
|
|
85
97
|
webサーバはnginxを立ててます。以下のようなディレクトリ構成です。変更作成したファイルは5つです。
|
1
2
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
お世話になります。
|
2
2
|
|
3
|
-
http
|
3
|
+
http://hoge.com/templates/index.html
|
4
|
-
|
4
|
+
|
5
|
-
http
|
5
|
+
http://hoge.com/templates/no2.htmlというURLをdjango上で表示させたいです。django1週間目です。
|
6
6
|
|
7
7
|
|
8
8
|
|