質問編集履歴
1
問題点の変更
test
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
ChoiceFieldでvaluesを文字として返したい。
|
test
CHANGED
@@ -1,774 +1,688 @@
|
|
1
|
-
###
|
1
|
+
### 問題点
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
|
6
|
-
|
7
|
-
|
3
|
+
choicesのvaluesを検索文字として使用しようとしているためChoiceの値を文字にしています。しかしchoiceの値が指定した順番の数値として表示されます。
|
4
|
+
|
8
|
-
|
5
|
+
(例)ramentaste =塩 values = 2
|
9
|
-
|
10
|
-
|
6
|
+
|
11
|
-
|
7
|
+
下記のサイトを参考にしたのですが理由がわかりません。
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
|
15
|
-
ご教授のほどお願い
|
9
|
+
ご教授のほどお願いします。
|
10
|
+
|
11
|
+
|
12
|
+
|
16
|
-
|
13
|
+
[https://qiita.com/mkizka/items/e1011aadbd1b22aca92d](https://qiita.com/mkizka/items/e1011aadbd1b22aca92d)
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
|
17
|
-
|
19
|
+
### イメージ画像
|
20
|
+
|
21
|
+
![イメージ説明](9a86a8b9e7b2209ab938169f16744915.png)
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
### ソースコード
|
18
26
|
|
19
27
|
```python
|
20
28
|
|
29
|
+
|
30
|
+
|
21
|
-
|
31
|
+
#models.py
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
32
|
+
|
26
|
-
|
27
|
-
|
33
|
+
|
28
|
-
|
29
|
-
|
34
|
+
|
30
|
-
|
31
|
-
from django.
|
35
|
+
from django.db import models
|
32
|
-
|
33
|
-
|
36
|
+
|
34
|
-
|
35
|
-
from django.views.generic.edit import CreateView, UpdateView, DeleteView
|
36
|
-
|
37
|
-
from django
|
37
|
+
from django.contrib.admin.widgets import AdminDateWidget
|
38
|
-
|
39
|
-
|
38
|
+
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
from .filters import ItemFilterSet
|
44
|
-
|
45
|
-
from
|
39
|
+
from django import forms
|
46
|
-
|
40
|
+
|
41
|
+
|
42
|
+
|
47
|
-
from .models import
|
43
|
+
from users.models import User
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
44
|
+
|
54
|
-
|
55
|
-
|
45
|
+
|
56
|
-
|
57
|
-
|
46
|
+
|
58
|
-
|
59
|
-
|
47
|
+
|
60
|
-
|
61
|
-
|
62
|
-
|
48
|
+
|
63
|
-
class Item
|
49
|
+
class Item(models.Model):
|
64
50
|
|
65
51
|
"""
|
66
52
|
|
53
|
+
データ定義クラス
|
54
|
+
|
67
|
-
|
55
|
+
各フィールドを定義する
|
56
|
+
|
68
|
-
|
57
|
+
参考:
|
58
|
+
|
69
|
-
|
59
|
+
・公式 モデルフィールドリファレンス
|
70
|
-
|
71
|
-
|
60
|
+
|
72
|
-
|
73
|
-
https://django
|
61
|
+
https://docs.djangoproject.com/ja/2.1/ref/models/fields/
|
74
62
|
|
75
63
|
"""
|
76
64
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
|
69
|
+
name = models.CharField(
|
70
|
+
|
71
|
+
verbose_name='ラーメン店',
|
72
|
+
|
73
|
+
max_length=20,
|
74
|
+
|
75
|
+
blank=True,
|
76
|
+
|
77
|
+
null=True,
|
78
|
+
|
79
|
+
)
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
name1 = models.CharField(
|
84
|
+
|
85
|
+
verbose_name='メニュー名称',
|
86
|
+
|
87
|
+
max_length=20,
|
88
|
+
|
89
|
+
blank=True,
|
90
|
+
|
91
|
+
null=True,
|
92
|
+
|
93
|
+
)
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
name2 = models.CharField(
|
98
|
+
|
99
|
+
verbose_name='都道府県',
|
100
|
+
|
101
|
+
max_length=20,
|
102
|
+
|
103
|
+
blank=True,
|
104
|
+
|
105
|
+
null=True,
|
106
|
+
|
107
|
+
)
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
name3 = models.CharField(
|
112
|
+
|
113
|
+
verbose_name='市区町村',
|
114
|
+
|
115
|
+
max_length=20,
|
116
|
+
|
117
|
+
blank=True,
|
118
|
+
|
119
|
+
null=True,
|
120
|
+
|
121
|
+
)
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
ramen_taste = (
|
128
|
+
|
129
|
+
('醤油', '醤油'),
|
130
|
+
|
131
|
+
('塩', '塩'),
|
132
|
+
|
133
|
+
('豚骨', '豚骨'),
|
134
|
+
|
135
|
+
('味噌', '味噌'),
|
136
|
+
|
137
|
+
('鶏白湯', '鶏白湯'),
|
138
|
+
|
139
|
+
('つけ麺', 'つけ麺'),
|
140
|
+
|
141
|
+
('担々麺', '担々麺'),
|
142
|
+
|
143
|
+
('油そば', '油そば'),
|
144
|
+
|
145
|
+
)
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
# サンプル項目1 ラーメンの味
|
150
|
+
|
151
|
+
sample_1 = models.TextField(
|
152
|
+
|
153
|
+
verbose_name='ラーメンジャンル',
|
154
|
+
|
155
|
+
choices=ramen_taste,
|
156
|
+
|
157
|
+
blank=True,
|
158
|
+
|
159
|
+
null=True,
|
160
|
+
|
161
|
+
)
|
162
|
+
|
163
|
+
|
164
|
+
|
165
|
+
|
166
|
+
|
167
|
+
# サンプル項目2 満足度合い
|
168
|
+
|
169
|
+
sample_satisfaction = models.IntegerField(
|
170
|
+
|
171
|
+
verbose_name='満足度評価',
|
172
|
+
|
173
|
+
blank=True,
|
174
|
+
|
175
|
+
null=True,
|
176
|
+
|
177
|
+
)
|
178
|
+
|
179
|
+
|
180
|
+
|
181
|
+
# サンプル項目3 こってり度合い
|
182
|
+
|
183
|
+
sample_3 = models.IntegerField(
|
184
|
+
|
185
|
+
verbose_name='こってりど評価',
|
186
|
+
|
187
|
+
blank=True,
|
188
|
+
|
189
|
+
null=True,
|
190
|
+
|
191
|
+
)
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
# サンプル項目4 辛さ度合い
|
196
|
+
|
197
|
+
sample_4 = models.IntegerField(
|
198
|
+
|
199
|
+
verbose_name='からさ評価',
|
200
|
+
|
201
|
+
blank=True,
|
202
|
+
|
203
|
+
null=True,
|
204
|
+
|
205
|
+
)
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
#サンプル項目 麺の太さ
|
210
|
+
|
211
|
+
ramen_hutosa = (
|
212
|
+
|
213
|
+
(1, '極細麺(1.1mm)'),
|
214
|
+
|
215
|
+
(2, '細麺(1.15mm)'),
|
216
|
+
|
217
|
+
(3, '中細麺(1.25mm)'),
|
218
|
+
|
219
|
+
(4, '中太麺(1.4mm)'),
|
220
|
+
|
221
|
+
(5, '太麺(1.7〜1.875mm)'),
|
222
|
+
|
223
|
+
(6, '極太麺(2.2〜2.5mm)'),
|
224
|
+
|
225
|
+
)
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
sample_menhutosa = models.IntegerField(
|
230
|
+
|
231
|
+
verbose_name='麺の太さ',
|
232
|
+
|
233
|
+
choices=ramen_hutosa,
|
234
|
+
|
235
|
+
blank=True,
|
236
|
+
|
237
|
+
null=True,
|
238
|
+
|
239
|
+
)
|
240
|
+
|
241
|
+
|
242
|
+
|
243
|
+
# サンプル項目5 値段評価
|
244
|
+
|
245
|
+
sample_5 = models.IntegerField(
|
246
|
+
|
247
|
+
verbose_name='値段評価',
|
248
|
+
|
249
|
+
blank=True,
|
250
|
+
|
251
|
+
null=True,
|
252
|
+
|
253
|
+
)
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
#サンプル項目5.1 値段
|
258
|
+
|
259
|
+
sample_cost = models.TextField(
|
260
|
+
|
261
|
+
verbose_name='値段',
|
262
|
+
|
263
|
+
max_length=10,
|
264
|
+
|
265
|
+
blank=True,
|
266
|
+
|
267
|
+
null=True,
|
268
|
+
|
269
|
+
)
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
# サンプル項目6 アクセス
|
274
|
+
|
275
|
+
sample_6 = models.IntegerField(
|
276
|
+
|
277
|
+
verbose_name='アクセス評価',
|
278
|
+
|
279
|
+
blank=True,
|
280
|
+
|
281
|
+
null=True,
|
282
|
+
|
283
|
+
)
|
284
|
+
|
285
|
+
|
286
|
+
|
287
|
+
#サンプル項目 URL
|
288
|
+
|
289
|
+
sample_url = models.URLField(
|
290
|
+
|
291
|
+
verbose_name='ホームページ',
|
292
|
+
|
293
|
+
max_length=100,
|
294
|
+
|
295
|
+
blank=True,
|
296
|
+
|
297
|
+
null=True,
|
298
|
+
|
299
|
+
)
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
#サンプル項目8 感想
|
304
|
+
|
305
|
+
memo = models.TextField(
|
306
|
+
|
307
|
+
verbose_name='コメント欄',
|
308
|
+
|
309
|
+
max_length=300,
|
310
|
+
|
311
|
+
blank=True,
|
312
|
+
|
313
|
+
null=True,
|
314
|
+
|
315
|
+
)
|
316
|
+
|
317
|
+
|
318
|
+
|
319
|
+
#サンプル項目9 来店日付
|
320
|
+
|
321
|
+
date = models.DateField(blank=True, null=True)
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
#サンプル項目10 画像
|
326
|
+
|
327
|
+
image = models.ImageField(
|
328
|
+
|
329
|
+
upload_to = '',
|
330
|
+
|
331
|
+
verbose_name='添付画像',
|
332
|
+
|
333
|
+
null=True,
|
334
|
+
|
335
|
+
blank=True,
|
336
|
+
|
337
|
+
)
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
# 以下、管理項目
|
346
|
+
|
347
|
+
|
348
|
+
|
349
|
+
# 作成者(ユーザー)
|
350
|
+
|
351
|
+
created_by = models.ForeignKey(
|
352
|
+
|
353
|
+
User,
|
354
|
+
|
355
|
+
verbose_name='作成者',
|
356
|
+
|
357
|
+
blank=True,
|
358
|
+
|
359
|
+
null=True,
|
360
|
+
|
361
|
+
related_name='CreatedBy',
|
362
|
+
|
363
|
+
on_delete=models.SET_NULL,
|
364
|
+
|
365
|
+
editable=False,
|
366
|
+
|
367
|
+
)
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
# 作成時間
|
372
|
+
|
373
|
+
created_at = models.DateTimeField(
|
374
|
+
|
375
|
+
verbose_name='作成時間',
|
376
|
+
|
377
|
+
blank=True,
|
378
|
+
|
379
|
+
null=True,
|
380
|
+
|
381
|
+
editable=False,
|
382
|
+
|
383
|
+
)
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
# 更新者(ユーザー)
|
388
|
+
|
389
|
+
updated_by = models.ForeignKey(
|
390
|
+
|
391
|
+
User,
|
392
|
+
|
393
|
+
verbose_name='更新者',
|
394
|
+
|
395
|
+
blank=True,
|
396
|
+
|
397
|
+
null=True,
|
398
|
+
|
399
|
+
related_name='UpdatedBy',
|
400
|
+
|
401
|
+
on_delete=models.SET_NULL,
|
402
|
+
|
403
|
+
editable=False,
|
404
|
+
|
405
|
+
)
|
406
|
+
|
407
|
+
|
408
|
+
|
409
|
+
# 更新時間
|
410
|
+
|
411
|
+
updated_at = models.DateTimeField(
|
412
|
+
|
413
|
+
verbose_name='更新時間',
|
414
|
+
|
415
|
+
blank=True,
|
416
|
+
|
417
|
+
null=True,
|
418
|
+
|
419
|
+
editable=False,
|
420
|
+
|
421
|
+
)
|
422
|
+
|
423
|
+
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
def __str__(self):
|
98
428
|
|
99
429
|
"""
|
100
430
|
|
101
|
-
リク
|
431
|
+
リストボックスや管理画面での表示
|
102
|
-
|
103
|
-
セッション変数の管理:一覧画面と詳細画面間の移動時に検索条件が維持されるようにする。
|
104
432
|
|
105
433
|
"""
|
106
434
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
435
|
+
return self.name
|
436
|
+
|
437
|
+
|
438
|
+
|
439
|
+
class Meta:
|
440
|
+
|
441
|
+
"""
|
442
|
+
|
443
|
+
管理画面でのタイトル表示
|
444
|
+
|
445
|
+
"""
|
446
|
+
|
447
|
+
verbose_name = '検索'
|
448
|
+
|
449
|
+
verbose_name_plural = '検索'
|
450
|
+
|
451
|
+
|
452
|
+
|
453
|
+
```
|
454
|
+
|
455
|
+
|
456
|
+
|
457
|
+
```html
|
458
|
+
|
459
|
+
#form.html
|
460
|
+
|
461
|
+
<form method="post" enctype="multipart/form-data">
|
462
|
+
|
463
|
+
{% extends "./_base.html" %}
|
464
|
+
|
465
|
+
{% block content %}
|
466
|
+
|
467
|
+
{% load crispy_forms_tags %}
|
468
|
+
|
469
|
+
<div class="container">
|
470
|
+
|
471
|
+
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
|
472
|
+
|
473
|
+
<div class="modal-dialog" role="document">
|
474
|
+
|
475
|
+
<div class="modal-content">
|
476
|
+
|
477
|
+
<div class="modal-header">
|
478
|
+
|
479
|
+
<h5 class="modal-title">検索条件</h5>
|
480
|
+
|
481
|
+
<button type="button" class="close" data-dismiss="modal" aria-label="閉じる">
|
482
|
+
|
483
|
+
<span aria-hidden="true">×</span>
|
484
|
+
|
485
|
+
</button>
|
486
|
+
|
487
|
+
</div>
|
488
|
+
|
489
|
+
<form id="filter" method="get">
|
490
|
+
|
491
|
+
<div class="modal-body">
|
492
|
+
|
493
|
+
{{ filter.form|crispy }}
|
494
|
+
|
495
|
+
</div>
|
496
|
+
|
497
|
+
</form>
|
498
|
+
|
499
|
+
<div class="modal-footer">
|
500
|
+
|
501
|
+
<a class="btn btn-outline-dark" data-dismiss="modal">戻る</a>
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
<button type="submit" class="btn btn-outline-dark" form="filter">検索</button>
|
506
|
+
|
507
|
+
</div>
|
508
|
+
|
509
|
+
</div>
|
510
|
+
|
511
|
+
</div>
|
512
|
+
|
513
|
+
</div>
|
514
|
+
|
515
|
+
<div class="row">
|
516
|
+
|
517
|
+
<div class="col-12">
|
518
|
+
|
519
|
+
<a class="btn btn-secondary filtered" style="visibility:hidden" href="/?page=1">検索を解除</a>
|
520
|
+
|
521
|
+
<div class="float-right mt-1">
|
522
|
+
|
523
|
+
<a class="btn btn-outline-dark" href="{% url 'create' %}">新規</a>
|
524
|
+
|
525
|
+
|
526
|
+
|
527
|
+
<form action=""method="get">
|
528
|
+
|
529
|
+
<input name="query" value="{{ request.GET.query }}" type="text">
|
530
|
+
|
531
|
+
<button type="submit">検索する</button>
|
532
|
+
|
533
|
+
</form>
|
534
|
+
|
535
|
+
|
536
|
+
|
537
|
+
|
538
|
+
|
539
|
+
</div>
|
540
|
+
|
541
|
+
</div>
|
542
|
+
|
543
|
+
</div>
|
166
544
|
|
167
545
|
|
168
546
|
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
""
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
""
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
class
|
198
|
-
|
199
|
-
""
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
""
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
""
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
def
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
i
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
i
|
260
|
-
|
261
|
-
item.
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
class
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
""
|
278
|
-
|
279
|
-
m
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
d
|
288
|
-
|
289
|
-
""
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
"""
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
i
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
class ItemDeleteView(LoginRequiredMixin, DeleteView):
|
312
|
-
|
313
|
-
"""
|
314
|
-
|
315
|
-
ビュー:削除画面
|
316
|
-
|
317
|
-
"""
|
318
|
-
|
319
|
-
model = Item
|
320
|
-
|
321
|
-
success_url = reverse_lazy('index')
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
def delete(self, request, *args, **kwargs):
|
326
|
-
|
327
|
-
"""
|
328
|
-
|
329
|
-
削除処理
|
330
|
-
|
331
|
-
"""
|
332
|
-
|
333
|
-
item = self.get_object()
|
334
|
-
|
335
|
-
item.delete()
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
return HttpResponseRedirect(self.success_url)
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
``````
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
```python
|
348
|
-
|
349
|
-
#models.py
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
from django.db import models
|
354
|
-
|
355
|
-
from django.contrib.admin.widgets import AdminDateWidget
|
356
|
-
|
357
|
-
from django import forms
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
from users.models import User
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
class Item(models.Model):
|
368
|
-
|
369
|
-
"""
|
370
|
-
|
371
|
-
データ定義クラス
|
372
|
-
|
373
|
-
各フィールドを定義する
|
374
|
-
|
375
|
-
参考:
|
376
|
-
|
377
|
-
・公式 モデルフィールドリファレンス
|
378
|
-
|
379
|
-
https://docs.djangoproject.com/ja/2.1/ref/models/fields/
|
380
|
-
|
381
|
-
"""
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
name = models.CharField(
|
388
|
-
|
389
|
-
verbose_name='ラーメン店',
|
390
|
-
|
391
|
-
max_length=20,
|
392
|
-
|
393
|
-
blank=True,
|
394
|
-
|
395
|
-
null=True,
|
396
|
-
|
397
|
-
)
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
name1 = models.CharField(
|
402
|
-
|
403
|
-
verbose_name='メニュー名称',
|
404
|
-
|
405
|
-
max_length=20,
|
406
|
-
|
407
|
-
blank=True,
|
408
|
-
|
409
|
-
null=True,
|
410
|
-
|
411
|
-
)
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
name2 = models.CharField(
|
416
|
-
|
417
|
-
verbose_name='都道府県',
|
418
|
-
|
419
|
-
max_length=20,
|
420
|
-
|
421
|
-
blank=True,
|
422
|
-
|
423
|
-
null=True,
|
424
|
-
|
425
|
-
)
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
name3 = models.CharField(
|
430
|
-
|
431
|
-
verbose_name='市区町村',
|
432
|
-
|
433
|
-
max_length=20,
|
434
|
-
|
435
|
-
blank=True,
|
436
|
-
|
437
|
-
null=True,
|
438
|
-
|
439
|
-
)
|
440
|
-
|
441
|
-
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
ramen_taste = (
|
446
|
-
|
447
|
-
(1, '醤油'),
|
448
|
-
|
449
|
-
(2, '塩'),
|
450
|
-
|
451
|
-
(3, '豚骨'),
|
452
|
-
|
453
|
-
(4, '味噌'),
|
454
|
-
|
455
|
-
(5, '鶏白湯'),
|
456
|
-
|
457
|
-
(6, 'つけ麺'),
|
458
|
-
|
459
|
-
(7, '担々麺'),
|
460
|
-
|
461
|
-
(8, '油そば'),
|
462
|
-
|
463
|
-
)
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
# サンプル項目1 ラーメンの味
|
468
|
-
|
469
|
-
sample_1 = models.IntegerField(
|
470
|
-
|
471
|
-
verbose_name='ラーメンジャンル',
|
472
|
-
|
473
|
-
choices=ramen_taste,
|
474
|
-
|
475
|
-
blank=True,
|
476
|
-
|
477
|
-
null=True,
|
478
|
-
|
479
|
-
)
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
484
|
-
|
485
|
-
# サンプル項目2 満足度合い
|
486
|
-
|
487
|
-
sample_satisfaction = models.IntegerField(
|
488
|
-
|
489
|
-
verbose_name='満足度評価',
|
490
|
-
|
491
|
-
blank=True,
|
492
|
-
|
493
|
-
null=True,
|
494
|
-
|
495
|
-
)
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
# サンプル項目3 こってり度合い
|
500
|
-
|
501
|
-
sample_3 = models.IntegerField(
|
502
|
-
|
503
|
-
verbose_name='こってりど評価',
|
504
|
-
|
505
|
-
blank=True,
|
506
|
-
|
507
|
-
null=True,
|
508
|
-
|
509
|
-
)
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
# サンプル項目4 辛さ度合い
|
514
|
-
|
515
|
-
sample_4 = models.IntegerField(
|
516
|
-
|
517
|
-
verbose_name='からさ評価',
|
518
|
-
|
519
|
-
blank=True,
|
520
|
-
|
521
|
-
null=True,
|
522
|
-
|
523
|
-
)
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
#サンプル項目 麺の太さ
|
528
|
-
|
529
|
-
ramen_hutosa = (
|
530
|
-
|
531
|
-
(1, '極細麺(1.1mm)'),
|
532
|
-
|
533
|
-
(2, '細麺(1.15mm)'),
|
534
|
-
|
535
|
-
(3, '中細麺(1.25mm)'),
|
536
|
-
|
537
|
-
(4, '中太麺(1.4mm)'),
|
538
|
-
|
539
|
-
(5, '太麺(1.7〜1.875mm)'),
|
540
|
-
|
541
|
-
(6, '極太麺(2.2〜2.5mm)'),
|
542
|
-
|
543
|
-
)
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
sample_menhutosa = models.IntegerField(
|
548
|
-
|
549
|
-
verbose_name='麺の太さ',
|
550
|
-
|
551
|
-
choices=ramen_hutosa,
|
552
|
-
|
553
|
-
blank=True,
|
554
|
-
|
555
|
-
null=True,
|
556
|
-
|
557
|
-
)
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
# サンプル項目5 値段評価
|
562
|
-
|
563
|
-
sample_5 = models.IntegerField(
|
564
|
-
|
565
|
-
verbose_name='値段評価',
|
566
|
-
|
567
|
-
blank=True,
|
568
|
-
|
569
|
-
null=True,
|
570
|
-
|
571
|
-
)
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
#サンプル項目5.1 値段
|
576
|
-
|
577
|
-
sample_cost = models.TextField(
|
578
|
-
|
579
|
-
verbose_name='値段',
|
580
|
-
|
581
|
-
max_length=10,
|
582
|
-
|
583
|
-
blank=True,
|
584
|
-
|
585
|
-
null=True,
|
586
|
-
|
587
|
-
)
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
# サンプル項目6 アクセス
|
592
|
-
|
593
|
-
sample_6 = models.IntegerField(
|
594
|
-
|
595
|
-
verbose_name='アクセス評価',
|
596
|
-
|
597
|
-
blank=True,
|
598
|
-
|
599
|
-
null=True,
|
600
|
-
|
601
|
-
)
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
#サンプル項目 URL
|
606
|
-
|
607
|
-
sample_url = models.URLField(
|
608
|
-
|
609
|
-
verbose_name='ホームページ',
|
610
|
-
|
611
|
-
max_length=100,
|
612
|
-
|
613
|
-
blank=True,
|
614
|
-
|
615
|
-
null=True,
|
616
|
-
|
617
|
-
)
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
#サンプル項目8 感想
|
622
|
-
|
623
|
-
memo = models.TextField(
|
624
|
-
|
625
|
-
verbose_name='コメント欄',
|
626
|
-
|
627
|
-
max_length=300,
|
628
|
-
|
629
|
-
blank=True,
|
630
|
-
|
631
|
-
null=True,
|
632
|
-
|
633
|
-
)
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
#サンプル項目9 来店日付
|
638
|
-
|
639
|
-
date = models.DateField(blank=True, null=True)
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
#サンプル項目10 画像
|
644
|
-
|
645
|
-
image = models.ImageField(
|
646
|
-
|
647
|
-
upload_to = '',
|
648
|
-
|
649
|
-
verbose_name='添付画像',
|
650
|
-
|
651
|
-
null=True,
|
652
|
-
|
653
|
-
blank=True,
|
654
|
-
|
655
|
-
)
|
656
|
-
|
657
|
-
|
658
|
-
|
659
|
-
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
# 以下、管理項目
|
664
|
-
|
665
|
-
|
666
|
-
|
667
|
-
# 作成者(ユーザー)
|
668
|
-
|
669
|
-
created_by = models.ForeignKey(
|
670
|
-
|
671
|
-
User,
|
672
|
-
|
673
|
-
verbose_name='作成者',
|
674
|
-
|
675
|
-
blank=True,
|
676
|
-
|
677
|
-
null=True,
|
678
|
-
|
679
|
-
related_name='CreatedBy',
|
680
|
-
|
681
|
-
on_delete=models.SET_NULL,
|
682
|
-
|
683
|
-
editable=False,
|
684
|
-
|
685
|
-
)
|
686
|
-
|
687
|
-
|
688
|
-
|
689
|
-
# 作成時間
|
690
|
-
|
691
|
-
created_at = models.DateTimeField(
|
692
|
-
|
693
|
-
verbose_name='作成時間',
|
694
|
-
|
695
|
-
blank=True,
|
696
|
-
|
697
|
-
null=True,
|
698
|
-
|
699
|
-
editable=False,
|
700
|
-
|
701
|
-
)
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
# 更新者(ユーザー)
|
706
|
-
|
707
|
-
updated_by = models.ForeignKey(
|
708
|
-
|
709
|
-
User,
|
710
|
-
|
711
|
-
verbose_name='更新者',
|
712
|
-
|
713
|
-
blank=True,
|
714
|
-
|
715
|
-
null=True,
|
716
|
-
|
717
|
-
related_name='UpdatedBy',
|
718
|
-
|
719
|
-
on_delete=models.SET_NULL,
|
720
|
-
|
721
|
-
editable=False,
|
722
|
-
|
723
|
-
)
|
724
|
-
|
725
|
-
|
726
|
-
|
727
|
-
# 更新時間
|
728
|
-
|
729
|
-
updated_at = models.DateTimeField(
|
730
|
-
|
731
|
-
verbose_name='更新時間',
|
732
|
-
|
733
|
-
blank=True,
|
734
|
-
|
735
|
-
null=True,
|
736
|
-
|
737
|
-
editable=False,
|
738
|
-
|
739
|
-
)
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
def __str__(self):
|
746
|
-
|
747
|
-
"""
|
748
|
-
|
749
|
-
リストボックスや管理画面での表示
|
750
|
-
|
751
|
-
"""
|
752
|
-
|
753
|
-
return self.name
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
class Meta:
|
758
|
-
|
759
|
-
"""
|
760
|
-
|
761
|
-
管理画面でのタイトル表示
|
762
|
-
|
763
|
-
"""
|
764
|
-
|
765
|
-
verbose_name = '検索'
|
766
|
-
|
767
|
-
verbose_name_plural = '検索'
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
547
|
+
<div class="row mt-3">
|
548
|
+
|
549
|
+
<div class="col-10 mx-auto">
|
550
|
+
|
551
|
+
{% include "./_pagination.html" %}
|
552
|
+
|
553
|
+
</div>
|
554
|
+
|
555
|
+
</div>
|
556
|
+
|
557
|
+
|
558
|
+
|
559
|
+
<div class="row">
|
560
|
+
|
561
|
+
<div class="col-12">
|
562
|
+
|
563
|
+
<ul class="list-group">
|
564
|
+
|
565
|
+
{% if item_list %}
|
566
|
+
|
567
|
+
{% for item in item_list %}
|
568
|
+
|
569
|
+
<li class="list-group-item">
|
570
|
+
|
571
|
+
{# item_detail_contents.html を参考に必要な項目を追加してください #}
|
572
|
+
|
573
|
+
|
574
|
+
|
575
|
+
<div class="row">
|
576
|
+
|
577
|
+
<div class="col-5 col-sm-3">
|
578
|
+
|
579
|
+
<p>1_ラーメン店</p>
|
580
|
+
|
581
|
+
</div>
|
582
|
+
|
583
|
+
<div class="col-7 col-sm-9">
|
584
|
+
|
585
|
+
<p>{{ item.name | default_if_none:"未入力" }}</p>
|
586
|
+
|
587
|
+
</div>
|
588
|
+
|
589
|
+
</div>
|
590
|
+
|
591
|
+
|
592
|
+
|
593
|
+
<div class="row">
|
594
|
+
|
595
|
+
<div class="col-5 col-sm-3">
|
596
|
+
|
597
|
+
<p>2_メニュー名称</p>
|
598
|
+
|
599
|
+
</div>
|
600
|
+
|
601
|
+
<div class="col-7 col-sm-9">
|
602
|
+
|
603
|
+
<p>{{ item.get_sample_1_display | default_if_none:"未入力" }}</p>
|
604
|
+
|
605
|
+
</div>
|
606
|
+
|
607
|
+
</div>
|
608
|
+
|
609
|
+
|
610
|
+
|
611
|
+
<div class="row">
|
612
|
+
|
613
|
+
<div class="col-5 col-sm-3">
|
614
|
+
|
615
|
+
<p>3_都道府県</p>
|
616
|
+
|
617
|
+
</div>
|
618
|
+
|
619
|
+
<div class="col-7 col-sm-9">
|
620
|
+
|
621
|
+
<p>{{ item.name2 | default_if_none:"未入力" }}</p>
|
622
|
+
|
623
|
+
</div>
|
624
|
+
|
625
|
+
</div>
|
626
|
+
|
627
|
+
|
628
|
+
|
629
|
+
<div class="row">
|
630
|
+
|
631
|
+
<div class="col-5 col-sm-3">
|
632
|
+
|
633
|
+
<p>4_市区町村</p>
|
634
|
+
|
635
|
+
</div>
|
636
|
+
|
637
|
+
<div class="col-7 col-sm-9">
|
638
|
+
|
639
|
+
<p>{{ item.name3 | default_if_none:"未入力" }}</p>
|
640
|
+
|
641
|
+
</div>
|
642
|
+
|
643
|
+
</div>
|
644
|
+
|
645
|
+
|
646
|
+
|
647
|
+
<div class="row">
|
648
|
+
|
649
|
+
<div class="col-5 col-sm-3">
|
650
|
+
|
651
|
+
<p>5_スープ味</p>
|
652
|
+
|
653
|
+
</div>
|
654
|
+
|
655
|
+
<div class="col-7 col-sm-9">
|
656
|
+
|
657
|
+
<p>{{ item.get_sample_1 | default_if_none:"未入力" }}</p>
|
658
|
+
|
659
|
+
</div>
|
660
|
+
|
661
|
+
</div>
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
<div class="row">
|
666
|
+
|
667
|
+
<div class="col-12">
|
668
|
+
|
669
|
+
<div class="float-right mt-1 mb-3">
|
670
|
+
|
671
|
+
<a class="btn btn-outline-dark" href="{% url 'create' %}">新規</a>
|
672
|
+
|
673
|
+
<a class="btn btn-outline-dark" data-toggle="modal" data-target="#myModal" href="#">検索</a>
|
674
|
+
|
675
|
+
</div>
|
676
|
+
|
677
|
+
</div>
|
678
|
+
|
679
|
+
</div>
|
680
|
+
|
681
|
+
</div>
|
682
|
+
|
683
|
+
{% endblock %}
|
684
|
+
|
685
|
+
</form>
|
772
686
|
|
773
687
|
|
774
688
|
|