質問するログイン新規登録

質問編集履歴

1

Chrome上エラーの追加、views.pyの追加

2021/02/28 16:14

投稿

nonono421
nonono421

スコア2

title CHANGED
File without changes
body CHANGED
@@ -6,8 +6,9 @@
6
6
 
7
7
  ### 発生している問題・コンソールに出力されるエラーメッセージ
8
8
 
9
- `SyntaxError: The string did not match the expected pattern.
9
+ Safari上のエラー`SyntaxError: The string did not match the expected pattern.`
10
- `
10
+ Chrome上のエラー`SyntaxError: Unexpected token < in JSON at position 2`
11
+
11
12
  下のソースコードのError2です。
12
13
  ### 該当のソースコード
13
14
 
@@ -70,6 +71,7 @@
70
71
  </html>
71
72
  ```
72
73
 
74
+ urls.py
73
75
  ```Python
74
76
  from django.urls import path
75
77
  from . import views
@@ -79,6 +81,26 @@
79
81
  ]
80
82
  ```
81
83
 
84
+ views.py
85
+
86
+ ```Python
87
+ from django.shortcuts import render
88
+
89
+ def index(request):
90
+ if request.method == "GET":
91
+ return render(
92
+ request,
93
+ "home.html",
94
+ )
95
+ else:
96
+ return render(
97
+ request,
98
+ "home.html",
99
+ {"title": 100}
100
+ )
101
+
102
+ ```
103
+
82
104
  ### 試したこと
83
105
 
84
106
  ・tokenの有無でデバッグしたので、token関係のエラーではないと思います。