- ubuntu12.04环境下使用kvm ioctl接口实现最简单的虚拟机
- Ubuntu 通过无线网络安装Ubuntu Server启动系统后连接无线网络的方法
- 在Ubuntu上搭建网桥的方法
- ubuntu 虚拟机上网方式及相关配置详解
CFSDN坚持开源创造价值,我们致力于搭建一个资源共享平台,让每一个IT人在这里找到属于你的精彩世界.
这篇CFSDN的博客文章python3.6+django2.0开发一套学员管理系统由作者收集整理,如果你对这篇文章有兴趣,记得点赞哟.
1.在pycharm中新建project demo1 添加app01 点击create按钮完成新建 。
2.在demo项目目录下新建目录static,并在settings.py中追加代码:
1
|
STATICFILES_DIRS
=
(os.path.join(BASE_DIR,
'static'
),)
|
3.在setting.py中添加模板路径:
1
2
3
4
5
6
7
8
9
10
11
12
|
TEMPLATES
=
[
{
'BACKEND'
:
'...'
,
'DIRS'
: [os.path.join(BASE_DIR,
'templates'
),],
'APP_DIRS'
: ...,
'OPTIONS'
: {
'context_processors'
: [
...
],
},
},
]
|
4.学员管理系统数据库设计:
在app01/model.py目录下建立 班级、老师、学生 、老师与班级关联表 四张表:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
from
django.db
import
models
# Create your models here.
class
Classes(models.Model):
'''
班级表
'''
title
=
models.CharField(max_length
=
32
)
a
=
models.ManyToManyField(
'Teachers'
)
class
Teachers(models.Model):
'''
老师表
'''
name
=
models.CharField(max_length
=
32
)
class
Students(models.Model):
username
=
models.CharField(max_length
=
32
)
age
=
models.IntegerField()
gender
=
models.BooleanField()
cs
=
models.ForeignKey(Classes,on_delete
=
models.CASCADE)
|
在终端Terminal 项目目录下执行数据表更新命令:
1
2
|
python manage.py makemigrations
python manage.py migrate
|
至此生成了四张数据表,可以在pycharm中,点开右上角的Database面板,然后将项目中templates目录下边的db.sqlite3鼠标拖拽到Database面板下,对新创建的数据表进行查看.
5.学员管理系统之班级管理:
为了方便分别操作班级、老师、学生相关的业务,将app01目录下的views.py 删掉,在app01目录下新建目录views,并在views目录下 新建classes.py teachers.py students.py.
1.在classes.py 中写 get_classes add_classes del_classes edit_classes四个函数,完成对 班级数据 的增删改查:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
from
django.shortcuts
import
render,redirect
from
app01
import
models
def
get_classes(request):
cls_list
=
models.Classes.objects.
all
()
return
render(request,
'get_classes.html'
,{
'cls_list'
:cls_list})
def
add_classes(request):
if
request.method
=
=
'GET'
:
return
render(request,
'add_classes.html'
)
elif
request.method
=
=
'POST'
:
title
=
request.POST.get(
'title'
,'')
models.Classes.objects.create(title
=
title)
return
redirect(
'/classes.html'
)
def
del_classes(request):
nid
=
request.GET.get(
'nid'
,'')
models.Classes.objects.
filter
(
id
=
nid).delete()
return
redirect(
'/classes.html'
)
def
edit_classes(request):
if
request.method
=
=
"GET"
:
nid
=
request.GET.get(
'nid'
, '')
obj
=
models.Classes.objects.get(
id
=
nid)
return
render(request,
'edit_classes.html'
,{
'obj'
:obj})
elif
request.method
=
=
"POST"
:
nid
=
request.POST.get(
'nid'
,'')
title
=
request.POST.get(
'xxoo'
,'')
models.Classes.objects.
filter
(
id
=
nid).update(title
=
title)
return
redirect(
'/classes.html'
)
|
2.在urls.py 中配置url路由: 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
from
django.contrib
import
admin
from
django.urls
import
path
from
app01.views
import
classes,students,teachers
urlpatterns
=
[
path(
'admin/'
, admin.site.urls),
path(
'classes.html'
, classes.get_classes),
path(
'add_classes.html'
, classes.add_classes),
path(
'del_classes.html'
, classes.del_classes),
path(
'edit_classes.html'
, classes.edit_classes),
# path('teachers.html', teachers.get_teachers),
# path('students.html', students.get_studernts),
]
|
3.在template目录下建立所需的html页面文件:
get_classes.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
style
>
tr td{ border:1px solid #000;text-align:center;}
</
style
>
<
meta
charset
=
"UTF-8"
>
<
title
>Title</
title
>
</
head
>
<
body
>
<
div
>
<
table
>
<
thead
>
<
tr
>
<
th
>ID</
th
> <
th
>名称</
th
> <
th
>操作</
th
>
</
tr
>
</
thead
>
<
tbody
>
{% for row in cls_list %}
<
tr
>
<
td
>{{ row.id }}</
td
>
<
td
>{{ row.title }}</
td
>
<
td
><
a
href
=
"/del_classes.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>删除</
a
>
|<
a
href
=
"/edit_classes.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>编辑</
a
>
</
td
>
</
tr
>
{% endfor %}
</
tbody
>
</
table
>
</
div
>
<
div
><
a
href
=
"/add_classes.html"
rel
=
"external nofollow"
rel
=
"external nofollow"
>添加</
a
> </
div
>
</
body
>
</
html
>
|
add_classes.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Title</
title
>
</
head
>
<
body
>
<
form
action
=
"/add_classes.html"
method
=
"post"
>
{% csrf_token %}
<
input
type
=
"text"
name
=
"title"
>
<
input
type
=
"submit"
value
=
"提交"
>
</
form
>
</
body
>
</
html
>
|
edit_classes.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Title</
title
>
</
head
>
<
body
>
<
form
method
=
"post"
action
=
"/edit_classes.html"
>
{% csrf_token %}
<
input
type
=
"hidden"
name
=
"nid"
value
=
"{{ obj.id }}"
>
<
input
type
=
"text"
name
=
"xxoo"
value
=
"{{ obj.title }}"
>
<
input
type
=
"submit"
value
=
"提交"
>
</
form
>
</
body
>
</
html
>
|
6.学员管理系统之学员管理: 1.在students.py 中写 get_students add_students del_students edit_students 四个函数,完成对 学生数据 的增删改查:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
from
django.shortcuts
import
render,redirect
from
app01
import
models
def
get_students(request):
stu_list
=
models.Students.objects.
all
()
return
render(request,
'get_students.html'
,{
'stu_list'
:stu_list})
def
add_students(request):
if
request.method
=
=
'GET'
:
cs_list
=
models.Classes.objects.
all
()
return
render(request,
'add_students.html'
,{
'cs_list'
:cs_list})
elif
request.method
=
=
'POST'
:
u
=
request.POST.get(
'username'
,'')
a
=
request.POST.get(
'age'
,'')
g
=
request.POST.get(
'gender'
,'')
c
=
request.POST.get(
'cs'
,'')
models.Students.objects.create(
username
=
u,
age
=
a,
gender
=
g,
cs_id
=
c
)
return
redirect(
'/students.html'
)
def
del_students(request):
nid
=
request.GET.get(
'nid'
, '')
models.Students.objects.
filter
(
id
=
nid).delete()
return
redirect(
'/students.html'
)
def
edit_students(request):
if
request.method
=
=
"GET"
:
nid
=
request.GET.get(
'nid'
, '')
obj
=
models.Students.objects.get(
id
=
nid)
cs_list
=
models.Classes.objects.
all
()
return
render(request,
'edit_students.html'
,{
'obj'
:obj,
'cs_list'
:cs_list})
elif
request.method
=
=
"POST"
:
nid
=
request.POST.get(
'nid'
,'')
u
=
request.POST.get(
'username'
, '')
a
=
request.POST.get(
'age'
, '')
g
=
request.POST.get(
'gender'
, '')
c
=
request.POST.get(
'cs'
, '')
models.Students.objects.
filter
(
id
=
nid).update(
username
=
u,
age
=
a,
gender
=
g,
cs_id
=
c)
return
redirect(
'/students.html'
)
|
2.在urls.py 中配置url路由: 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
from
django.contrib
import
admin
from
django.urls
import
path
from
app01.views
import
classes,students,teachers
urlpatterns
=
[
path(
'admin/'
, admin.site.urls),
path(
'classes.html'
, classes.get_classes),
path(
'add_classes.html'
, classes.add_classes),
path(
'del_classes.html'
, classes.del_classes),
path(
'edit_classes.html'
, classes.edit_classes),
path(
'students.html'
, students.get_students),
path(
'add_students.html'
, students.add_students),
path(
'del_students.html'
, students.del_students),
path(
'edit_students.html'
, students.edit_students),
# path('teachers.html', teachers.get_teachers),
]
|
3.在template目录下建立所需的html页面文件:
get_students.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
<!DOCTYPE html>
<html lang
=
"en"
>
<head>
<style>
tr td{ border:
1px
solid
#000;text-align:center;}
<
/
style>
<meta charset
=
"UTF-8"
>
<title>Title<
/
title>
<
/
head>
<body>
<div>
<table>
<thead>
<tr>
<th>
ID
<
/
th>
<th>姓名<
/
th>
<th>年龄<
/
th>
<th>性别<
/
th>
<th>班级<
/
th>
<th>操作<
/
th>
<
/
tr>
<
/
thead>
<tbody>
{
%
for
row
in
stu_list
%
}
<tr>
<td>{{ row.
id
}}<
/
td>
<td>{{ row.username }}<
/
td>
<td>{{ row.age }}<
/
td>
<td>{{ row.gender }}<
/
td>
<td>{{ row.cs.title }}<
/
td>
<td><a href
=
"/del_students.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>删除<
/
a>
|<a href
=
"/edit_students.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>编辑<
/
a>
<
/
td>
<
/
tr>
{
%
endfor
%
}
<
/
tbody>
<
/
table>
<
/
div>
<div><a href
=
"/add_students.html"
rel
=
"external nofollow"
rel
=
"external nofollow"
>添加<
/
a> <
/
div>
<
/
body>
<
/
html>
|
add_students 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Title</
title
>
</
head
>
<
body
>
<
h1
>添加用户</
h1
>
<
form
method
=
"post"
action
=
"/add_students.html"
>
{% csrf_token %}
<
p
><
input
type
=
"text"
name
=
"username"
placeholder
=
"用户名"
></
p
>
<
p
><
input
type
=
"text"
name
=
"age"
placeholder
=
"年龄"
></
p
>
<
p
>
男<
input
type
=
"radio"
name
=
"gender"
value
=
"1"
>
女<
input
type
=
"radio"
name
=
"gender"
value
=
"0"
>
</
p
>
<
p
>
<
select
name
=
"cs"
>
{% for row in cs_list %}
<
option
value
=
"{{ row.id }}"
>{{ row.title }}</
option
>
{% endfor %}
</
select
>
</
p
>
<
p
><
input
type
=
"submit"
value
=
"提交"
></
p
>
</
form
>
</
body
>
</
html
>
|
edit_students.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
<!DOCTYPE html>
<
html
lang
=
"en"
>
<
head
>
<
meta
charset
=
"UTF-8"
>
<
title
>Title</
title
>
</
head
>
<
body
>
<
h1
>编辑用户</
h1
>
<
form
method
=
"post"
action
=
"/edit_students.html"
>
{% csrf_token %}
<
input
type
=
"hidden"
name
=
"nid"
value
=
"{{ obj.id }}"
>
<
p
><
input
type
=
"text"
name
=
"username"
placeholder
=
"用户名"
></
p
>
<
p
><
input
type
=
"text"
name
=
"age"
placeholder
=
"年龄"
></
p
>
<
p
>
男<
input
type
=
"radio"
name
=
"gender"
value
=
"1"
>
女<
input
type
=
"radio"
name
=
"gender"
value
=
"0"
>
</
p
>
<
p
>
<
select
name
=
"cs"
>
{% for row in cs_list %}
<
option
value
=
"{{ row.id }}"
>{{ row.title }}</
option
>
{% endfor %}
</
select
>
</
p
>
<
p
><
input
type
=
"submit"
value
=
"提交"
></
p
>
</
form
>
</
body
>
</
html
>
|
7.学员管理系统之给班级分配老师:
在teachers数据表中增加一些老师信息:
在pycharm右上角的Database打开面板,然后将template目录下边的db.splte3鼠标拖入到Database面板中,打开db==》app01_teachers表 。
点击“+”,然后填入老师信息,然后点击有“DB”标志的向上箭头,进行数据保存.
1.在classes.py中增加set_teachers函数 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
def
set_teachers(request):
if
request.method
=
=
'GET'
:
nid
=
request.GET.get(
'nid'
,'')
cls_obj
=
models.Classes.objects.get(
id
=
nid)
cls_teacher_list
=
cls_obj.a.
all
()
all_teacher_list
=
models.Teachers.objects.
all
()
return
render(request,
'set_teachers.html'
,{
'cls_teacher_list'
:cls_teacher_list,
'all_teacher_list'
:all_teacher_list,
'nid'
:nid,
})
elif
request.method
=
=
'POST'
:
nid
=
request.POST.get(
'nid'
, '')
ids_str
=
request.POST.getlist(
'teacher_id'
,'')
ids_int
=
[]
for
i
in
ids_str:
i
=
int
(i)
ids_int.append(i)
obj
=
models.Classes.objects.get(
id
=
nid)
obj.a.
set
(ids_int)
return
redirect(
'/classes.html'
)
|
2.在urls.py 中配置url路由: 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
from
django.contrib
import
admin
from
django.urls
import
path
from
app01.views
import
classes,students,teachers
urlpatterns
=
[
path(
'admin/'
, admin.site.urls),
path(
'classes.html'
, classes.get_classes),
path(
'add_classes.html'
, classes.add_classes),
path(
'del_classes.html'
, classes.del_classes),
path(
'edit_classes.html'
, classes.edit_classes),
path(
'students.html'
, students.get_students),
path(
'add_students.html'
, students.add_students),
path(
'del_students.html'
, students.del_students),
path(
'edit_students.html'
, students.edit_students),
path(
'set_teachers.html'
, classes.set_teachers),
]
|
3.在template目录下建立所需的html页面文件:
set_teachers.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
<!DOCTYPE html>
<html lang
=
"en"
>
<head>
<meta charset
=
"UTF-8"
>
<title>Title<
/
title>
<
/
head>
<body>
<form action
=
"/set_teachers.html"
method
=
"post"
>
<
input
type
=
"hidden"
name
=
"nid"
value
=
"{{ nid }}"
>
{
%
csrf_token
%
}
<select multiple size
=
"10"
name
=
"teacher_id"
>
{
%
for
item
in
all_teacher_list
%
}
{
%
if
item
in
cls_teacher_list
%
}
<option value
=
"{{ item.id }}"
selected
=
"selected"
>{{ item.name }}<
/
option>
{
%
else
%
}
<option value
=
"{{ item.id }}"
>{{ item.name }}<
/
option>
{
%
endif
%
}
{
%
endfor
%
}
<
/
select>
<
input
type
=
"submit"
value
=
"提交"
>
<
/
form>
<
/
body>
<
/
html>
|
对get_classes.html进行增添修改为:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
<!DOCTYPE html>
<html lang
=
"en"
>
<head>
<meta charset
=
"UTF-8"
>
<title>Title<
/
title>
<
/
head>
<body>
<div>
<table>
<thead>
<tr>
<th>
ID
<
/
th> <th>名称<
/
th> <th>任课老师<
/
th> <th>操作<
/
th>
<
/
tr>
<
/
thead>
<tbody>
{
%
for
row
in
cls_list
%
}
<tr>
<td>{{ row.
id
}}<
/
td>
<td>{{ row.title }}<
/
td>
<td>
{
%
for
item
in
row.a.
all
%
}
<span>{{ item.name }}<
/
span>
{
%
endfor
%
}
<
/
td>
<td><a href
=
"/del_classes.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>删除<
/
a>
|<a href
=
"/edit_classes.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>编辑<
/
a>
|<a href
=
"/set_teachers.html?nid={{ row.id }}"
rel
=
"external nofollow"
>分配老师<
/
a>
<
/
td>
<
/
tr>
{
%
endfor
%
}
<
/
tbody>
<
/
table>
<
/
div>
<div><a href
=
"/add_classes.html"
rel
=
"external nofollow"
rel
=
"external nofollow"
>添加<
/
a> <
/
div>
<
/
body>
<
/
html>
|
8.初识Ajax 。
Ajax是异步传输方式,偷偷的向后台发请求,不引起页面刷新,下面通过一个小例子来认识Ajax这种数据传输方式.
首先下载jQuery导入项目下的static目录下 。
1.在app01/Views目录下新建ajax.py 。
1
2
3
4
5
6
7
8
9
10
11
|
from
django.shortcuts
import
render,redirect,HttpResponse
def
ajax1(request):
return
render(request,
'ajax1.html'
)
def
ajax2(request):
u
=
request.GET.get(
'username'
)
p
=
request.GET.get(
'password'
)
return
HttpResponse(
'我愿意'
)
|
2.在urls.py中配置相关路由 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
from
django.contrib
import
admin
from
django.urls
import
path
from
app01.views
import
classes,students,teachers,ajax
urlpatterns
=
[
path(
'admin/'
, admin.site.urls),
path(
'classes.html'
, classes.get_classes),
path(
'add_classes.html'
, classes.add_classes),
path(
'del_classes.html'
, classes.del_classes),
path(
'edit_classes.html'
, classes.edit_classes),
path(
'students.html'
, students.get_students),
path(
'add_students.html'
, students.add_students),
path(
'del_students.html'
, students.del_students),
path(
'edit_students.html'
, students.edit_students),
path(
'set_teachers.html'
, classes.set_teachers),
path(
'ajax1.html'
, ajax.ajax1),
path(
'ajax2.html'
, ajax.ajax2),
]
|
3.在template目录下新建ajax1.html 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
<!DOCTYPE html>
<html lang
=
"en"
>
<head>
<meta charset
=
"UTF-8"
>
<title>Title<
/
title>
<style>
.btn{
display: inline
-
block;
padding:
5px
15px
;
background
-
color: coral;
color: white;
cursor: pointer;
}
<
/
style>
<
/
head>
<body>
<div>
<
input
placeholder
=
"用户名"
type
=
"text"
>
<
input
placeholder
=
"密码"
type
=
"password"
>
<div
class
=
"btn"
>提交<
/
div>
<
/
div>
<script src
=
"/static/jquery-3.3.1.js"
><
/
script>
<script>
function submitForm() {
var u
=
$(
'#username'
).val();
var p
=
$(
'#password'
).val();
$.ajax({
url:
'ajax2.html'
,
type
:
'GET'
,
data:{username:u,password:p},
success:function (arg) {
/
/
回调函数 arg是服务器返回的字符串
console.log(arg)
}
})
}
<
/
script>
<
/
body>
<
/
html>
|
9.学员管理系统之Ajax删除学员: 1.在ajax.py中增加ajax4函数 。
1
2
3
4
5
6
7
8
9
|
from
app01
import
models
def
ajax4(request):
nid
=
request.GET.get(
'nid'
)
msg
=
'成功'
try
:
models.Students.objects.get(
id
=
nid).delete()
except
Exception as e:
msg
=
str
(e)
return
HttpResponse(msg)
|
2.在urls.py中配置相关路由 。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
from
django.contrib
import
admin
from
django.urls
import
path
from
app01.views
import
classes,students,teachers,ajax
urlpatterns
=
[
path(
'admin/'
, admin.site.urls),
path(
'classes.html'
, classes.get_classes),
path(
'add_classes.html'
, classes.add_classes),
path(
'del_classes.html'
, classes.del_classes),
path(
'edit_classes.html'
, classes.edit_classes),
path(
'students.html'
, students.get_students),
path(
'add_students.html'
, students.add_students),
path(
'del_students.html'
, students.del_students),
path(
'edit_students.html'
, students.edit_students),
path(
'set_teachers.html'
, classes.set_teachers),
path(
'ajax1.html'
, ajax.ajax1),
path(
'ajax2.html'
, ajax.ajax2),
path(
'ajax4.html'
, ajax.ajax4),
]
|
3.对get_students.html进行添加修改:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
<!DOCTYPE html>
<html lang
=
"en"
>
<head>
<meta charset
=
"UTF-8"
>
<title>Title<
/
title>
<
/
head>
<body>
<div>
<table>
<thead>
<tr>
<th>
ID
<
/
th>
<th>姓名<
/
th>
<th>年龄<
/
th>
<th>性别<
/
th>
<th>班级<
/
th>
<th>操作<
/
th>
<
/
tr>
<
/
thead>
<tbody>
{
%
for
row
in
stu_list
%
}
<tr nid
=
"{{ row.id }}"
>
<td>{{ row.
id
}}<
/
td>
<td>{{ row.username }}<
/
td>
<td>{{ row.age }}<
/
td>
<td>{{ row.gender }}<
/
td>
<td>{{ row.cs.title }}<
/
td>
<td><a href
=
"/del_students.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>删除<
/
a>
|<a href
=
"#"
rel
=
"external nofollow"
>Ajax删除<
/
a>
|<a href
=
"/edit_students.html?nid={{ row.id }}"
rel
=
"external nofollow"
rel
=
"external nofollow"
>编辑<
/
a>
<
/
td>
<
/
tr>
{
%
endfor
%
}
<
/
tbody>
<
/
table>
<
/
div>
<div><a href
=
"/add_students.html"
rel
=
"external nofollow"
rel
=
"external nofollow"
>添加<
/
a> <
/
div>
<
/
body>
<script src
=
"/static/jquery-3.3.1.js"
><
/
script>
<script>
function removeStudent(ths) {
var nid
=
$(ths).parent().parent().attr(
'nid'
);
$.ajax({
url:
'/ajax4.html'
,
type
:
'GET'
,
data:{nid:nid},
success:function (arg) {
if
(arg
=
=
'成功'
){
window.location.
reload
();
}
else
{
alert(arg);
}
}
})
}
<
/
script>
<
/
html>
|
原文链接:https://www.cnblogs.com/xuepangzi/p/8493853.html 。
最后此篇关于python3.6+django2.0开发一套学员管理系统的文章就讲到这里了,如果你想了解更多关于python3.6+django2.0开发一套学员管理系统的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。
我正在处理一组标记为 160 个组的 173k 点。我想通过合并最接近的(到 9 或 10 个组)来减少组/集群的数量。我搜索过 sklearn 或类似的库,但没有成功。 我猜它只是通过 knn 聚类
我有一个扁平数字列表,这些数字逻辑上以 3 为一组,其中每个三元组是 (number, __ignored, flag[0 or 1]),例如: [7,56,1, 8,0,0, 2,0,0, 6,1,
我正在使用 pipenv 来管理我的包。我想编写一个 python 脚本来调用另一个使用不同虚拟环境(VE)的 python 脚本。 如何运行使用 VE1 的 python 脚本 1 并调用另一个 p
假设我有一个文件 script.py 位于 path = "foo/bar/script.py"。我正在寻找一种在 Python 中通过函数 execute_script() 从我的主要 Python
这听起来像是谜语或笑话,但实际上我还没有找到这个问题的答案。 问题到底是什么? 我想运行 2 个脚本。在第一个脚本中,我调用另一个脚本,但我希望它们继续并行,而不是在两个单独的线程中。主要是我不希望第
我有一个带有 python 2.5.5 的软件。我想发送一个命令,该命令将在 python 2.7.5 中启动一个脚本,然后继续执行该脚本。 我试过用 #!python2.7.5 和http://re
我在 python 命令行(使用 python 2.7)中,并尝试运行 Python 脚本。我的操作系统是 Windows 7。我已将我的目录设置为包含我所有脚本的文件夹,使用: os.chdir("
剧透:部分解决(见最后)。 以下是使用 Python 嵌入的代码示例: #include int main(int argc, char** argv) { Py_SetPythonHome
假设我有以下列表,对应于及时的股票价格: prices = [1, 3, 7, 10, 9, 8, 5, 3, 6, 8, 12, 9, 6, 10, 13, 8, 4, 11] 我想确定以下总体上最
所以我试图在选择某个单选按钮时更改此框架的背景。 我的框架位于一个类中,并且单选按钮的功能位于该类之外。 (这样我就可以在所有其他框架上调用它们。) 问题是每当我选择单选按钮时都会出现以下错误: co
我正在尝试将字符串与 python 中的正则表达式进行比较,如下所示, #!/usr/bin/env python3 import re str1 = "Expecting property name
考虑以下原型(prototype) Boost.Python 模块,该模块从单独的 C++ 头文件中引入类“D”。 /* file: a/b.cpp */ BOOST_PYTHON_MODULE(c)
如何编写一个程序来“识别函数调用的行号?” python 检查模块提供了定位行号的选项,但是, def di(): return inspect.currentframe().f_back.f_l
我已经使用 macports 安装了 Python 2.7,并且由于我的 $PATH 变量,这就是我输入 $ python 时得到的变量。然而,virtualenv 默认使用 Python 2.6,除
我只想问如何加快 python 上的 re.search 速度。 我有一个很长的字符串行,长度为 176861(即带有一些符号的字母数字字符),我使用此函数测试了该行以进行研究: def getExe
list1= [u'%app%%General%%Council%', u'%people%', u'%people%%Regional%%Council%%Mandate%', u'%ppp%%Ge
这个问题在这里已经有了答案: Is it Pythonic to use list comprehensions for just side effects? (7 个答案) 关闭 4 个月前。 告
我想用 Python 将两个列表组合成一个列表,方法如下: a = [1,1,1,2,2,2,3,3,3,3] b= ["Sun", "is", "bright", "June","and" ,"Ju
我正在运行带有最新 Boost 发行版 (1.55.0) 的 Mac OS X 10.8.4 (Darwin 12.4.0)。我正在按照说明 here构建包含在我的发行版中的教程 Boost-Pyth
学习 Python,我正在尝试制作一个没有任何第 3 方库的网络抓取工具,这样过程对我来说并没有简化,而且我知道我在做什么。我浏览了一些在线资源,但所有这些都让我对某些事情感到困惑。 html 看起来
我是一名优秀的程序员,十分优秀!