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

質問編集履歴

5

再編集

2021/03/23 09:14

投稿

nan_c
nan_c

スコア4

title CHANGED
File without changes
body CHANGED
@@ -1,6 +1,6 @@
1
1
  入力項目に対してファイルnotdefinedの時に入力項目の下に「受付番号が存在しません。」のエラーを表示させたいです。
2
2
 
3
- vies.pyから「doc.html」にパラメータ渡してredirectしています。
3
+ vies.pyから「doc.html」にパラメータ渡して再表示しています。
4
4
  msg1等は表示されていますがModal項目であるreceipt_numberが表示されずブランク表示されてしまいます。
5
5
  処理は以下に抜粋しました。
6
6
  ご教示よろしく御願いします。
@@ -21,8 +21,8 @@
21
21
  msg5=msg5))
22
22
  redirect_url = ('/wdd/create_doc.html')
23
23
  url = f'{redirect_url}?{parameters}'
24
+ # 画面の再描画
24
- return redirect(url)
25
+ return render(request, redirect_url, parameters)
25
-
26
26
  ```
27
27
  ```Modal
28
28
  <a href="#" data-toggle="modal" data-target="#receipt_number_dialog1">検索</a>

4

内容修正

2021/03/23 09:14

投稿

nan_c
nan_c

スコア4

title CHANGED
File without changes
body CHANGED
@@ -1,31 +1,31 @@
1
+ 入力項目に対してファイルnotdefinedの時に入力項目の下に「受付番号が存在しません。」のエラーを表示させたいです。
2
+
1
- vies.pyから「doc.html」パラメータ渡しています。
3
+ vies.pyから「doc.html」パラメータ渡してredirectしています。
2
- msg1等は表示されていますがModal項目であるreceipt1_numberが表示されずブランク表示されてしまいます。
4
+ msg1等は表示されていますがModal項目であるreceipt_numberが表示されずブランク表示されてしまいます。
3
5
  処理は以下に抜粋しました。
4
6
  ご教示よろしく御願いします。
5
7
 
6
8
  ```Python
7
9
  (viws.py)
10
+ if not Info.objects.filter(id=receipt_number).exists():
11
+ msg1 = (" ")
12
+ msg2 = ("受付番号が存在しません。")
13
+ msg3 = (" ")
14
+ msg4 = (" ")
15
+ msg5 = (" ")
16
+ parameters = urlencode(dict(receipt_number=receipt_number,
17
+ msg1=msg1,
18
+ msg2=msg2,
19
+ msg3=msg3,
20
+ msg4=msg4,
21
+ msg5=msg5))
22
+ redirect_url = ('/wdd/create_doc.html')
23
+ url = f'{redirect_url}?{parameters}'
8
- return render(
24
+ return redirect(url)
9
- request,
10
- 'doc.html',
11
- {
12
- 'form': form,
13
- 'user_function_authority': user_function_authority,
14
- 'files': files,
15
- 'is_admin': is_admin,
16
- 'receipt1_number': byreceipt_number,
17
- 'receipt2_number': byreceipt_number,
18
- 'msg1': msg1,
19
- 'msg2': msg2,
20
- 'msg3': msg3,
21
- 'msg4': msg4,
22
- 'msg5': msg5
23
- }
24
- )
25
25
 
26
26
  ```
27
27
  ```Modal
28
- <a href="#" data-toggle="modal" data-target="#bycatch_receipt_number_dialog1">検索</a>
28
+ <a href="#" data-toggle="modal" data-target="#receipt_number_dialog1">検索</a>
29
29
  ```
30
30
 
31
31
  ```Python
@@ -33,17 +33,16 @@
33
33
  <script type="text/javascript">
34
34
  $(function () {
35
35
  $(document).ready(function() {
36
- $('#id_bycatch1_receipt_number').val({{ receipt1_number }});
36
+ $('#id_bycatch_receipt_number').val({{ receipt_number }});
37
- $('#id_bycatch2_receipt_number').val({{ receipt2_number }});
38
37
  });
39
38
  })
40
39
  </script>
41
40
  ```
42
41
 
43
42
  ここで「receipt1_number」まで受け渡されていますがmodalへのセットがうまくいきません。
44
- デバッグすると「receipt_number」の値が「ICRY-1300」となっていて「ICRY NOT DEFINED」のエラーとなっています。
43
+ デバッグすると「jQuery.Deferred.exceptionHook = function( error, stack ) {error = ReferenceError: ICRY is not defined at HTMLDocument.<anonymous> (http://127.0.0.1:8000/wdd/create_doc.html?byreceipt_number=ICRY-13-000&msg1=+&msg2=%E5%8F%97%E4%BB%98%E7%95%AA%E5%8F%B7%E3%81%8C%E5%AD%98%E5%9C%A8%E3%81%97%E3%81%BE%E3%81%9B%E3%82%93%E3%80%82&msg3=+&msg4=+&msg5=+:968:24) at mightThrow (http://127.0.0.1:8000/static/jquery-3.5.1/jquery-3.5.1.js:3762:29) at process (http://127.0.0.1:8000/static/jquery-3.5.1/jquery-3.5.1.js:3830:12), stack = undefined
45
44
 
46
- 本来は「"ICRY-1300"」となっていたいです。
45
+ のエラーとなっていす。
47
46
 
48
47
 
49
48
  よろしく御願いします。

3

デバッグ内容を追記

2021/03/23 07:56

投稿

nan_c
nan_c

スコア4

title CHANGED
File without changes
body CHANGED
@@ -41,5 +41,9 @@
41
41
  ```
42
42
 
43
43
  ここで「receipt1_number」まで受け渡されていますがmodalへのセットがうまくいきません。
44
+ デバッグすると「receipt_number」の値が「ICRY-1300」となっていて「ICRY NOT DEFINED」のエラーとなっています。
44
45
 
46
+ 本来は「"ICRY-1300"」となっていたいです。
47
+
48
+
45
49
  よろしく御願いします。

2

修正

2021/03/23 06:53

投稿

nan_c
nan_c

スコア4

title CHANGED
File without changes
body CHANGED
@@ -13,8 +13,6 @@
13
13
  'user_function_authority': user_function_authority,
14
14
  'files': files,
15
15
  'is_admin': is_admin,
16
- 'queryset_Bycatch': queryset_Bycatch,
17
- 'queryset_IndividualInfoCommercialWhalingLedgers': queryset_IndividualInfoCommercialWhalingLedgers,
18
16
  'receipt1_number': byreceipt_number,
19
17
  'receipt2_number': byreceipt_number,
20
18
  'msg1': msg1,
@@ -36,7 +34,7 @@
36
34
  $(function () {
37
35
  $(document).ready(function() {
38
36
  $('#id_bycatch1_receipt_number').val({{ receipt1_number }});
39
- $('#id_bycatch2_receipt_number').val({{ receipt1_number }});
37
+ $('#id_bycatch2_receipt_number').val({{ receipt2_number }});
40
38
  });
41
39
  })
42
40
  </script>

1

javascript編集

2021/03/23 05:55

投稿

nan_c
nan_c

スコア4

title CHANGED
File without changes
body CHANGED
@@ -32,10 +32,16 @@
32
32
 
33
33
  ```Python
34
34
  (doc.html)
35
- <script type="text/javascript"><!--
35
+ <script type="text/javascript">
36
- function a(){
36
+ $(function () {
37
+ $(document).ready(function() {
37
- $('#id_receipt1_number').val(receipt1_number);
38
+ $('#id_bycatch1_receipt_number').val({{ receipt1_number }});
38
- $('#id_receipt2_number').val(receipt2_number);
39
+ $('#id_bycatch2_receipt_number').val({{ receipt1_number }});
40
+ });
39
- }
41
+ })
40
- --></script>
42
+ </script>
41
- ```
43
+ ```
44
+
45
+ ここで「receipt1_number」まで受け渡されていますがmodalへのセットがうまくいきません。
46
+
47
+ よろしく御願いします。