質問編集履歴
2
htmlの雛形
title
CHANGED
File without changes
|
body
CHANGED
@@ -76,4 +76,126 @@
|
|
76
76
|
my_dict['myid1'] = request.POST['id']
|
77
77
|
my_dict['myid2'] = str(ans)
|
78
78
|
return render(request, 'myapp/index.html', my_dict)
|
79
|
+
```
|
80
|
+
|
81
|
+
POST後に表示するwebページ
|
82
|
+
```html
|
83
|
+
<!DOCTYPE html>
|
84
|
+
<head>
|
85
|
+
<meta charset="UTF-8">
|
86
|
+
<title>Testpage</title>
|
87
|
+
</script>
|
88
|
+
</head>
|
89
|
+
<body>
|
90
|
+
<div id="users">
|
91
|
+
<form action="" caption="search songs">
|
92
|
+
<input type="text" class="search">
|
93
|
+
</form>
|
94
|
+
<table id="myTable" class="tablesorter">
|
95
|
+
<thead>
|
96
|
+
<tr>
|
97
|
+
<th class="sort" data-sort="type1">type1</th>
|
98
|
+
...(中略)...
|
99
|
+
<th class="sort" data-sort="type7">type7</th>
|
100
|
+
</tr>
|
101
|
+
</thead>
|
102
|
+
<tbody class="list">
|
103
|
+
(各種データ)
|
104
|
+
</tbody>
|
105
|
+
</table>
|
106
|
+
<div class="pager">
|
107
|
+
<ul class="pagination"></ul>
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.5.0/list.min.js"></script>
|
111
|
+
<script>
|
112
|
+
var options = {
|
113
|
+
valueNames:['type1', 'type2', 'type3', 'type4', 'type5', 'type6', 'type7' ],
|
114
|
+
page: 25,
|
115
|
+
pagination:{
|
116
|
+
paginationClass:'pagination',
|
117
|
+
innerWindow:2,
|
118
|
+
outerWindow:1,
|
119
|
+
}
|
120
|
+
};
|
121
|
+
var userList = new List('users', options);
|
122
|
+
|
123
|
+
userList.on('sortStart', function(a){
|
124
|
+
console.log(a.i);
|
125
|
+
a.i=1;
|
126
|
+
});
|
127
|
+
userList.sort('title', {order : 'asc'});
|
128
|
+
</script>
|
129
|
+
|
130
|
+
<style>
|
131
|
+
.sort.desc:after{
|
132
|
+
content:'▼';
|
133
|
+
}
|
134
|
+
.sort.asc:after{
|
135
|
+
content:"▲";
|
136
|
+
}
|
137
|
+
</style>
|
138
|
+
|
139
|
+
<style>
|
140
|
+
/* style for pager and pagination from http://wwx.jp/css-pagination*/
|
141
|
+
.pager {
|
142
|
+
overflow: hidden;
|
143
|
+
}
|
144
|
+
|
145
|
+
.pager ul {
|
146
|
+
list-style: none;
|
147
|
+
position: relative;
|
148
|
+
left: 50%;
|
149
|
+
float: left;
|
150
|
+
}
|
151
|
+
|
152
|
+
.pager ul li {
|
153
|
+
margin: 0 1px;
|
154
|
+
position: relative;
|
155
|
+
left: -50%;
|
156
|
+
float: left;
|
157
|
+
}
|
158
|
+
|
159
|
+
.pager ul li span,
|
160
|
+
.pager ul li a {
|
161
|
+
display: block;
|
162
|
+
font-size: 16px;
|
163
|
+
padding: 0.6em 1em;
|
164
|
+
border-radius: 3px;
|
165
|
+
}
|
166
|
+
|
167
|
+
.pager ul li a {
|
168
|
+
background: #EEE;
|
169
|
+
color: #000;
|
170
|
+
text-decoration: none;
|
171
|
+
}
|
172
|
+
|
173
|
+
.pager ul li a:hover {
|
174
|
+
background: #333;
|
175
|
+
color: #FFF;
|
176
|
+
}
|
177
|
+
|
178
|
+
/* added by myself */
|
179
|
+
.pager ul li.active{
|
180
|
+
font-weight: bold;
|
181
|
+
}
|
182
|
+
|
183
|
+
table{
|
184
|
+
width: 100%;
|
185
|
+
border-collapse: collapse;
|
186
|
+
border-spacing: 0;
|
187
|
+
}
|
188
|
+
|
189
|
+
table th,table td{
|
190
|
+
padding: 10px 0;
|
191
|
+
text-align: center;
|
192
|
+
}
|
193
|
+
|
194
|
+
table tr:nth-child(odd){
|
195
|
+
background-color: #eee
|
196
|
+
}
|
197
|
+
</style>
|
198
|
+
</body>
|
199
|
+
</html>
|
200
|
+
|
79
201
|
```
|
1
2つめの疑問について
title
CHANGED
File without changes
|
body
CHANGED
@@ -55,4 +55,25 @@
|
|
55
55
|
### 補足情報(FW/ツールのバージョンなど)
|
56
56
|
|
57
57
|
python 3.7.3 64-bit
|
58
|
-
Django 3.0.5
|
58
|
+
Django 3.0.5
|
59
|
+
|
60
|
+
# 追記
|
61
|
+
views.py
|
62
|
+
```python
|
63
|
+
from django.shortcuts import render
|
64
|
+
from django.http import HttpResponse
|
65
|
+
from .forms import myForm
|
66
|
+
from .mymodule import myfunc
|
67
|
+
import os
|
68
|
+
import json
|
69
|
+
|
70
|
+
def index(request):
|
71
|
+
my_dict = {'myid1':'',
|
72
|
+
'myid2':''
|
73
|
+
}
|
74
|
+
if(request.method == 'POST'):
|
75
|
+
ans = mumodule(request.POST['id'])
|
76
|
+
my_dict['myid1'] = request.POST['id']
|
77
|
+
my_dict['myid2'] = str(ans)
|
78
|
+
return render(request, 'myapp/index.html', my_dict)
|
79
|
+
```
|