質問編集履歴
2
htmlの雛形
test
CHANGED
File without changes
|
test
CHANGED
@@ -155,3 +155,247 @@
|
|
155
155
|
return render(request, 'myapp/index.html', my_dict)
|
156
156
|
|
157
157
|
```
|
158
|
+
|
159
|
+
|
160
|
+
|
161
|
+
POST後に表示するwebページ
|
162
|
+
|
163
|
+
```html
|
164
|
+
|
165
|
+
<!DOCTYPE html>
|
166
|
+
|
167
|
+
<head>
|
168
|
+
|
169
|
+
<meta charset="UTF-8">
|
170
|
+
|
171
|
+
<title>Testpage</title>
|
172
|
+
|
173
|
+
</script>
|
174
|
+
|
175
|
+
</head>
|
176
|
+
|
177
|
+
<body>
|
178
|
+
|
179
|
+
<div id="users">
|
180
|
+
|
181
|
+
<form action="" caption="search songs">
|
182
|
+
|
183
|
+
<input type="text" class="search">
|
184
|
+
|
185
|
+
</form>
|
186
|
+
|
187
|
+
<table id="myTable" class="tablesorter">
|
188
|
+
|
189
|
+
<thead>
|
190
|
+
|
191
|
+
<tr>
|
192
|
+
|
193
|
+
<th class="sort" data-sort="type1">type1</th>
|
194
|
+
|
195
|
+
...(中略)...
|
196
|
+
|
197
|
+
<th class="sort" data-sort="type7">type7</th>
|
198
|
+
|
199
|
+
</tr>
|
200
|
+
|
201
|
+
</thead>
|
202
|
+
|
203
|
+
<tbody class="list">
|
204
|
+
|
205
|
+
(各種データ)
|
206
|
+
|
207
|
+
</tbody>
|
208
|
+
|
209
|
+
</table>
|
210
|
+
|
211
|
+
<div class="pager">
|
212
|
+
|
213
|
+
<ul class="pagination"></ul>
|
214
|
+
|
215
|
+
</div>
|
216
|
+
|
217
|
+
</div>
|
218
|
+
|
219
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
|
220
|
+
|
221
|
+
<script>
|
222
|
+
|
223
|
+
var options = {
|
224
|
+
|
225
|
+
valueNames:['type1', 'type2', 'type3', 'type4', 'type5', 'type6', 'type7' ],
|
226
|
+
|
227
|
+
page: 25,
|
228
|
+
|
229
|
+
pagination:{
|
230
|
+
|
231
|
+
paginationClass:'pagination',
|
232
|
+
|
233
|
+
innerWindow:2,
|
234
|
+
|
235
|
+
outerWindow:1,
|
236
|
+
|
237
|
+
}
|
238
|
+
|
239
|
+
};
|
240
|
+
|
241
|
+
var userList = new List('users', options);
|
242
|
+
|
243
|
+
|
244
|
+
|
245
|
+
userList.on('sortStart', function(a){
|
246
|
+
|
247
|
+
console.log(a.i);
|
248
|
+
|
249
|
+
a.i=1;
|
250
|
+
|
251
|
+
});
|
252
|
+
|
253
|
+
userList.sort('title', {order : 'asc'});
|
254
|
+
|
255
|
+
</script>
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
<style>
|
260
|
+
|
261
|
+
.sort.desc:after{
|
262
|
+
|
263
|
+
content:'▼';
|
264
|
+
|
265
|
+
}
|
266
|
+
|
267
|
+
.sort.asc:after{
|
268
|
+
|
269
|
+
content:"▲";
|
270
|
+
|
271
|
+
}
|
272
|
+
|
273
|
+
</style>
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
<style>
|
278
|
+
|
279
|
+
/* style for pager and pagination from http://wwx.jp/css-pagination*/
|
280
|
+
|
281
|
+
.pager {
|
282
|
+
|
283
|
+
overflow: hidden;
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
.pager ul {
|
290
|
+
|
291
|
+
list-style: none;
|
292
|
+
|
293
|
+
position: relative;
|
294
|
+
|
295
|
+
left: 50%;
|
296
|
+
|
297
|
+
float: left;
|
298
|
+
|
299
|
+
}
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
.pager ul li {
|
304
|
+
|
305
|
+
margin: 0 1px;
|
306
|
+
|
307
|
+
position: relative;
|
308
|
+
|
309
|
+
left: -50%;
|
310
|
+
|
311
|
+
float: left;
|
312
|
+
|
313
|
+
}
|
314
|
+
|
315
|
+
|
316
|
+
|
317
|
+
.pager ul li span,
|
318
|
+
|
319
|
+
.pager ul li a {
|
320
|
+
|
321
|
+
display: block;
|
322
|
+
|
323
|
+
font-size: 16px;
|
324
|
+
|
325
|
+
padding: 0.6em 1em;
|
326
|
+
|
327
|
+
border-radius: 3px;
|
328
|
+
|
329
|
+
}
|
330
|
+
|
331
|
+
|
332
|
+
|
333
|
+
.pager ul li a {
|
334
|
+
|
335
|
+
background: #EEE;
|
336
|
+
|
337
|
+
color: #000;
|
338
|
+
|
339
|
+
text-decoration: none;
|
340
|
+
|
341
|
+
}
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
.pager ul li a:hover {
|
346
|
+
|
347
|
+
background: #333;
|
348
|
+
|
349
|
+
color: #FFF;
|
350
|
+
|
351
|
+
}
|
352
|
+
|
353
|
+
|
354
|
+
|
355
|
+
/* added by myself */
|
356
|
+
|
357
|
+
.pager ul li.active{
|
358
|
+
|
359
|
+
font-weight: bold;
|
360
|
+
|
361
|
+
}
|
362
|
+
|
363
|
+
|
364
|
+
|
365
|
+
table{
|
366
|
+
|
367
|
+
width: 100%;
|
368
|
+
|
369
|
+
border-collapse: collapse;
|
370
|
+
|
371
|
+
border-spacing: 0;
|
372
|
+
|
373
|
+
}
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
table th,table td{
|
378
|
+
|
379
|
+
padding: 10px 0;
|
380
|
+
|
381
|
+
text-align: center;
|
382
|
+
|
383
|
+
}
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
table tr:nth-child(odd){
|
388
|
+
|
389
|
+
background-color: #eee
|
390
|
+
|
391
|
+
}
|
392
|
+
|
393
|
+
</style>
|
394
|
+
|
395
|
+
</body>
|
396
|
+
|
397
|
+
</html>
|
398
|
+
|
399
|
+
|
400
|
+
|
401
|
+
```
|
1
2つめの疑問について
test
CHANGED
File without changes
|
test
CHANGED
@@ -113,3 +113,45 @@
|
|
113
113
|
python 3.7.3 64-bit
|
114
114
|
|
115
115
|
Django 3.0.5
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
# 追記
|
120
|
+
|
121
|
+
views.py
|
122
|
+
|
123
|
+
```python
|
124
|
+
|
125
|
+
from django.shortcuts import render
|
126
|
+
|
127
|
+
from django.http import HttpResponse
|
128
|
+
|
129
|
+
from .forms import myForm
|
130
|
+
|
131
|
+
from .mymodule import myfunc
|
132
|
+
|
133
|
+
import os
|
134
|
+
|
135
|
+
import json
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
def index(request):
|
140
|
+
|
141
|
+
my_dict = {'myid1':'',
|
142
|
+
|
143
|
+
'myid2':''
|
144
|
+
|
145
|
+
}
|
146
|
+
|
147
|
+
if(request.method == 'POST'):
|
148
|
+
|
149
|
+
ans = mumodule(request.POST['id'])
|
150
|
+
|
151
|
+
my_dict['myid1'] = request.POST['id']
|
152
|
+
|
153
|
+
my_dict['myid2'] = str(ans)
|
154
|
+
|
155
|
+
return render(request, 'myapp/index.html', my_dict)
|
156
|
+
|
157
|
+
```
|