这几天做了学期实训项目,构建IB智慧交通系统,用的是django+bootstrap4+mysql。下面是一些部分代码与效果展示图,在暑假时会向大家展示详细过程。
在某一个页面的一些代码:
<li class="active">
<a href="index.html"><i class="fa fa-th-large"></i> <span class="nav-label">首页信息</span> <span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li class="active"><a href='{% url 'index' %}'>员工信息管理</a></li>
<li><a href="{% url 'che_liang' %}">车辆信息管理</a></li>
<li><a href="{% url 'zhan_dian' %}">站点信息管理</a></li>
<li><a href="{% url 'xian_lu' %}">线路信息管理</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-bar-chart-o"></i> <span class="nav-label">基础数据</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
<li><a href="{% url 'graph_flot' %}">基础数据</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-edit"></i> <span class="nav-label">排班信息</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
<li><a href="{% url 'form_basic' %}">排班信息</a></li>
</ul>
</li>
<li>
<a href="#"><i class="fa fa-table"></i> <span class="nav-label">关系查看</span><span class="fa arrow"></span></a>
<ul class="nav nav-second-level collapse">
<li><a href="{% url 'table_basic' %}">关系查看</a></li>
</ul>
</li>
<tbody>
{% for line in find_user_list %}
<tr>
<td>{{line.code}}</td>
<td>{{line.loginname}}</td>
<td>{{line.password}}</td>
<td>{{line.name}}</td>
<td>{{line.phone}}</td>
<td>{{line.idcard}}</td>
<td>{{line.driving}}</td>
<td>{{line.status}}</td>
<td>{{line.role.rolename}}</td>
</tr>
{% endfor %}
</tbody>
在首页只有选择数据库中已经启用的用户,才能登录,而且不同的用户,有管理员,调度员和驾驶员进入不同的页面:
数据库用户表:
管理员登录,可以进行所有信息管理:
调度员登录,只可以修改排班信息:
如果把其禁用后,就登录不上了:
这里的界面并不友好,只是为了方便大家查看,完整项目中有界面友好的选项。
驾驶员登录,只能查看排班信息:
禁用的驾驶员登录:
启动的驾驶员登陆:
我们添加一个信息:
只有选择驾驶员后才会出现驾龄选项,其他角色默认驾龄为0。
我们删除一个用户,比如删除5号驾驶员:
我们可以看到已经删除成功了。
这里让我们修改用户编号为22的员工信息:
可以看到,已经修改成功了。
我们在选择框中查看员工信息:
但是101与102号站点由于与线路表有外键约束,因此删除不了它们:
这个外键约束是什么呢?其实是线路表中用到了该站点,如果你想要删除它或者修改它,必须要先把用到它的表先删除包含它的信息。
我们先常识修改一下线路表引用的站点信息:
发现并不能修改,我们查看线路表和线路站点关系:
原来是线路站点关系在外部已经设置好了。
我们就只能修改没有约束的站点:
这里没有在线路站点表中,为我们添加的线路选择站点,因此需要我们在线路站点关系表中为其分配:
然后我们就可以看到我们添加的线路1003对应的站点了:
由于线路和站点有约束关系,因此删除时需要注意,如下:
只有没有指定线路站点关系的线路才能删除,也就是没有站点的空线路。
修改时也是只有选择空线路,才能修改。
这里要遵循的原则是,选择的线路编号是线路表已经启运的,车牌号是车辆表中启运的车,司机编号是用户表中角色是驾驶员而且已经启动的驾驶员。
我们先把车辆表中的所有车辆状态改为启运:
然后把用户表中的所有驾驶员进行启动:
然后再排班表中,发现我们可以选择了:
我们先添加几个排班信息:
然后修改排班编号为100033的排班信息:
这里略过
这里要注意的是,如果你的排班信息中已经选择了其他表的数据,那么其他表的对应数据就不能删除和修改了。
urls.py文件:
# url网页目录
from django.urls import path,re_path
from . import view
urlpatterns = [
# 两个必选参数:route、view 和两个可选参数:kwargs、name
# route: 字符串,表示 URL 规则,与之匹配的 URL 会执行对应的第二个参数 view。
# view: 用于执行与正则表达式匹配的 URL 请求。
# kwargs: 视图使用的字典类型的参数。
# name: 用来反向获取 URL。
# path('', view.hello),
# Django >= 2.0 的版本,urls.py的django.conf.urls已经被django.urls取代
# Django >= 2.0 的版本,path() 函数无法匹配正则表达式,需要使用 re_path() 即可匹配正则表达式
# 首页
re_path(r'^$',view.dengLu),
# 登录后接受表单跳转页面
path('tiao_zhuan',view.getDengLu,name="dengLu"),
# 选择其他按钮后跳转页面
path('denglu',view.dengLu,name="deng_lu"),
path('index',view.index,name='index'),
path('che_liang',view.che_liang,name='che_liang'), # 这里设置name,为了在模板文件中,写name,就能找到这个路由
path('zhan_dian',view.zhan_dian,name='zhan_dian'),
path('xian_lu',view.xian_lu,name='xian_lu'),
path('graph_flot',view.graph_flot,name='graph_flot'),
path('form_basic',view.form_basic,name='form_basic'),
path('table_basic',view.table_basic,name='table_basic'),
# 员工
path('my_index',view.save_user,name="form"),
path('my_delete',view.delete_user,name="form2"),
path('my_modify',view.modify_user,name="form3"),
path('index_find',view.chaXun_user,name="form4"),
# 车辆
path('che_liang_index',view.che_save,name="che_liang_form"),
path('che_liang_delete',view.che_delete,name="che_liang_form2"),
path('che_liang_modify',view.che_modify,name="che_liang_form3"),
path('che_liang_find',view.chaXun_che,name="che_liang_form4"),
# 站点
path('zhan_dian_index',view.zhan_dian_save,name="zhan_dian_form"),
path('zhan_dian_delete',view.zhan_dian_delete,name="zhan_dian_form2"),
path('zhan_dian_modify',view.zhan_dian_modify,name="zhan_dian_form3"),
path('zhan_dian_find',view.chaXun_zhan_dian,name="zhan_dian_form4"),
# 线路
path('xian_lu_index',view.xian_lu_save,name="xian_lu_form"),
path('xian_lu_delete',view.xian_lu_delete,name="xian_lu_form2"),
path('xian_lu_modify',view.xian_lu_modify,name="xian_lu_form3"),
path('xian_lu_find',view.chaXun_xian_lu,name="xian_lu_form4"),
# 排班
path("pai_ban_index",view.pai_ban_save,name="pai_ban_form"),
path("pai_ban_delete",view.pai_ban_delete,name="pai_ban_form2"),
path("pai_ban_modify",view.pai_ban_modify,name="pai_ban_form3"),
path("form_basic_find",view.chaXun_pai_ban,name="pai_ban_form4"),
]
view.py视图文件:
from django.shortcuts import render
from shuJuKu.models import *
def dengLu(request):
# 登陆管理
return render(request, "denglu.html")
def getDengLu(request):
# 用户登录后跳转页面
username = request.POST.get("username")
userpassword = request.POST.get("userpassword")
response = Sysuser.objects.filter(loginname=username,password=userpassword)
if response:
for i in response:
quan_xian = i.role.rolecode
zhuang_tai = i.status
if quan_xian == 0:
return render(request, "index.html")
if quan_xian == 1 and zhuang_tai == '启动':
schedul_list = Scheduling.objects.all()
return render(request,"form_basic_diao_du.html",{"schedul_list":schedul_list})
elif quan_xian == 2 and zhuang_tai == '启动':
schedul_list = Scheduling.objects.all()
return render(request, "form_basic_look.html",{"schedul_list":schedul_list})
else:
return 0
def index(request):
# 用户表管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Sysuser.objects.all()
return render(request,"index.html",{"user_list": my_list})
def che_liang(request):
# 车辆表管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Bus.objects.all()
return render(request, 'che_liang.html',{"cheLiang_list": my_list})
def zhan_dian(request):
# 站点表管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Station.objects.all()
return render(request, 'zhan_dian.html',{"zhanDian_list":my_list})
def xian_lu(request):
# 线路表管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Line.objects.all()
a = {}
for i in my_list:
my_linecode = i.linecode
response = LineStationRef.objects.filter(linecode=my_linecode)
b = []
for j in response:
b.append(j.stationcode.stationname)
a[my_linecode] = b
return render(request, 'xian_lu.html',{"xianLu_list":my_list,"a":a})
def graph_flot(request):
# 基础数据管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Role.objects.all()
my_list2 = Permission.objects.all()
return render(request, 'graph_flot.html',{"role_list":my_list,"primission":my_list2})
def form_basic(request):
# 排班表管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = Scheduling.objects.all()
return render(request, 'form_basic.html',{"schedul_list":my_list})
def table_basic(request):
# 关系数据管理
# 通过objects这个模型管理器的all()获得所有数据行,相当于SQL中的SELECT * FROM
my_list = RolePermissionRef.objects.all()
my_list2 = LineStationRef.objects.all()
return render(request, 'table_basic.html',{"guanXi_list":my_list,"guanXi2_list":my_list2})
# 处理表单
# 接收POST请求数据
# 用户操作
def save_user(request):
all_list = {}
# 保存员工信息增加数据
if request.method == 'POST':
code = request.POST.get('code')
loginName = request.POST.get('loginName')
password = request.POST.get('password')
name = request.POST.get('name')
phone = request.POST.get('phone')
idCard = request.POST.get('idCard')
role = request.POST.get('role')
driving = request.POST.get('driving')
status = request.POST.get('status')
if driving=='':
driving = 0
my_role = Role.objects.filter(rolename=role)
for i in my_role:
user = Sysuser(code=code,loginname=loginName,password=password,name=name,phone=phone,idcard=idCard,
role=i,driving=driving,status=status)
user.save()
all_list = {"code":code, "loginName":loginName, "password":password, "name":name,
"phone":phone, "idCard":idCard, "driving":driving,"status":status,"role":role}
return render(request,'my_index.html',{"user_list2":all_list})
def delete_user(request):
all_list = {}
# 删除员工信息
if request.method == 'POST':
aa = request.POST.get("my_delete")
Sysuser.objects.filter(code=aa).delete()
return render(request, 'index.html')
def modify_user(request):
# 修改员工信息
if request.method == 'POST':
code = request.POST.get('code')
code2 = request.POST.get('code2')
loginName = request.POST.get('loginName')
password = request.POST.get('password')
name = request.POST.get('name')
phone = request.POST.get('phone')
idCard = request.POST.get('idCard')
role = request.POST.get('role')
driving = request.POST.get('driving')
status = request.POST.get('status')
if driving=='':
driving = 0
my_role = Role.objects.filter(rolename=role)
for i in my_role:
Sysuser.objects.filter(code=code).update(code=code2,loginname=loginName,password=password,
role=i,name=name,phone=phone,idcard=idCard,driving=driving,status=status)
return render(request, 'index.html')
def chaXun_user(request):
if request.method == 'POST':
one = request.POST.get('one')
two = request.POST.get('two')
response = Sysuser.objects.filter(loginname=one,status=two)
return render(request,'index_find.html',{'find_user_list':response})
# 车辆操作
def che_save(request):
all_list = {}
# 保存车辆信息增加数据
if request.method == 'POST':
busCode = request.POST.get('busCode')
busLicense = request.POST.get('busLicense')
busType = request.POST.get('busType')
busStatus = request.POST.get('busStatus')
startTime = request.POST.get('startTime')
this_bus = Bus(buscode=busCode,buslicense=busLicense,bustype=busType,busstatus=busStatus,
starttime=startTime)
this_bus.save()
return render(request,'che_liang.html')
def che_delete(request):
all_list = {}
# 删除车辆信息
if request.method == 'POST':
aa = request.POST.get("my_delete")
Bus.objects.filter(buscode=aa).delete()
return render(request, 'che_liang.html')
def che_modify(request):
all_list = {}
# 修改车辆信息
if request.method == 'POST':
busCode = request.POST.get('busCode')
busCode2 = request.POST.get('busCode2')
busLicense = request.POST.get('busLicense')
busType = request.POST.get('busType')
busStatus = request.POST.get('busStatus')
startTime = request.POST.get('startTime')
Bus.objects.filter(buscode=busCode).update(buscode=busCode2,buslicense=busLicense,bustype=busType,busstatus=busStatus,
starttime=startTime)
return render(request,'che_liang.html')
def chaXun_che(request):
if request.method == 'POST':
one = request.POST.get('one')
two = request.POST.get('two')
response = Bus.objects.filter(buslicense=one,busstatus=two)
return render(request,'che_liang_find.html',{'find_user_list':response})
# 站点
def zhan_dian_save(request):
all_list = {}
# 保存站点信息增加数据
if request.method == 'POST':
stationCode = request.POST.get('stationCode')
stationName = request.POST.get('stationName')
longitude = request.POST.get('longitude')
latitude = request.POST.get('latitude')
region = request.POST.get('region')
street = request.POST.get('street')
this_zhan_dian = Station(stationcode=stationCode,stationname=stationName,longitude=longitude,
latitude=latitude,region=region,street=street)
this_zhan_dian.save()
return render(request,'zhan_dian.html')
def zhan_dian_delete(request):
all_list = {}
# 删除站点信息
if request.method == 'POST':
aa = request.POST.get("my_delete")
Station.objects.filter(stationcode=aa).delete()
return render(request, 'zhan_dian.html')
def zhan_dian_modify(request):
all_list = {}
# 修改站点信息
if request.method == 'POST':
stationCode = request.POST.get('stationCode')
stationCode2 = request.POST.get('stationCode2')
stationName = request.POST.get('stationName')
longitude = request.POST.get('longitude')
latitude = request.POST.get('latitude')
region = request.POST.get('region')
street = request.POST.get('street')
Station.objects.filter(stationcode=stationCode).update(stationcode=stationCode2,stationname=stationName,longitude=longitude,
latitude=latitude,region=region,street=street)
return render(request,'zhan_dian.html')
def chaXun_zhan_dian(request):
if request.method == 'POST':
one = request.POST.get('one')
two = request.POST.get('two')
three = request.POST.get('three')
response = Station.objects.filter(stationname=one,region=two,street=three)
return render(request,'zhan_dian_find.html',{'find_user_list':response})
# 线路
def xian_lu_save(request):
all_list = {}
# 保存线路信息增加数据
if request.method == 'POST':
lineCode = request.POST.get('lineCode')
lineName = request.POST.get('lineName')
status = request.POST.get('status')
startLineTime = request.POST.get('startLineTime')
direction = request.POST.get('direction')
xian_lu_dian = Line(linecode=lineCode,linename=lineName,status=status,
startlinetime=startLineTime,direction=direction)
xian_lu_dian.save()
return render(request,'xian_lu.html')
def xian_lu_delete(request):
all_list = {}
# 删除线路信息
if request.method == 'POST':
aa = request.POST.get("my_delete")
Line.objects.filter(linecode=aa).delete()
return render(request, 'xian_lu.html')
def xian_lu_modify(request):
all_list = {}
# 修改线路信息
if request.method == 'POST':
lineCode = request.POST.get('lineCode')
lineCode2 = request.POST.get('lineCode2')
lineName = request.POST.get('lineName')
status = request.POST.get('status')
startLineTime = request.POST.get('startLineTime')
direction = request.POST.get('direction')
xian_lu_dian = Line.objects.filter(linecode=lineCode).update(linecode2=lineCode2,linename=lineName,status=status,
startlinetime=startLineTime,direction=direction)
xian_lu_dian.save()
return render(request,'xian_lu.html')
def chaXun_xian_lu(request):
if request.method == 'POST':
one = request.POST.get('one')
two = request.POST.get('two')
three = request.POST.get('three')
response = Line.objects.filter(linename=one,direction=two,status=three)
print(response)
return render(request,'xian_lu_find.html',{'find_user_list':response})
# 排班
def pai_ban_save(request):
# 保存排班信息增加数据
all_list1 = {} # 存储线路编号
all_list2 = {} # 存储车牌号
all_list3 = {} # 存储司机编号
all_list4 = {} # 存储始发站
all_list5 = {} # 存储终点站
for i in Line.objects.all():
all_list1[i] = i.linecode
for i in Bus.objects.all():
# 判断汽车是否启运
if i.busstatus == '启运':
all_list2[i] = i.buslicense
else:
continue
for i in Sysuser.objects.all():
# 判断是否为司机
k = i.role.rolecode
if k == 2:
all_list3[i] = i.code
else:
continue
for i in Station.objects.all():
all_list4[i] = i.stationname
for i in Station.objects.all():
all_list5[i] = i.stationname
if request.method == 'POST':
code = request.POST.get('code')
lineCode = request.POST.get('lineCode')
busLicense = request.POST.get('busLicense')
tcNumber = request.POST.get('tcNumber')
tcTime = request.POST.get('tcTime')
userCode = request.POST.get('userCode')
startStation = request.POST.get('startStation')
endStation = request.POST.get('endStation')
user = Scheduling(code=code)
# 线路编号
lineCode = Line.objects.filter(linecode=lineCode)
for i in lineCode:
user.linecode = i
# 车牌号
busLicense = Bus.objects.filter(buslicense=busLicense)
for i in busLicense:
user.buslicense = i
# 趟次
user.tcnumber = tcNumber
# 每趟时间
user.tctime = tcTime
# 司机编号
userCode = Sysuser.objects.filter(code=userCode)
for i in userCode:
user.usercode = i
# 始发站
startStation = Station.objects.filter(stationname=startStation)
for i in startStation:
user.startstation = i
# 终点站
endStation = Station.objects.filter(stationname=endStation)
for i in endStation:
user.endstation = i
user.save()
return render(request,'form_basic.html',{"lineCode":all_list1,"busLicense":all_list2,"userCode":all_list3,
"startStation":all_list4,"endStation":all_list5})
def pai_ban_delete(request):
all_list = {}
# 删除排班信息
if request.method == 'POST':
aa = request.POST.get("my_delete")
Scheduling.objects.filter(code=aa).delete()
return render(request, 'form_basic.html')
def pai_ban_modify(request):
# 修改排班信息
all_list1 = {} # 存储线路编号
all_list2 = {} # 存储车牌号
all_list3 = {} # 存储司机编号
all_list4 = {} # 存储始发站
all_list5 = {} # 存储终点站
for i in Line.objects.all():
all_list1[i] = i.linecode
for i in Bus.objects.all():
# 判断汽车是否启运
if i.busstatus == '启运':
all_list2[i] = i.buslicense
else:
continue
for i in Sysuser.objects.all():
# 判断是否为司机
k = i.role.rolecode
if k == 2:
all_list3[i] = i.code
else:
continue
for i in Station.objects.all():
all_list4[i] = i.stationname
for i in Station.objects.all():
all_list5[i] = i.stationname
if request.method == 'POST':
code = request.POST.get('code')
code2 = request.POST.get('code2')
lineCode = request.POST.get('lineCode')
busLicense = request.POST.get('busLicense')
tcNumber = request.POST.get('tcNumber')
tcTime = request.POST.get('tcTime')
userCode = request.POST.get('userCode')
startStation = request.POST.get('startStation')
endStation = request.POST.get('endStation')
user = Scheduling.objects.filter(code=code).update(code=code2)
# 线路编号
lineCode = Line.objects.filter(linecode=lineCode)
for i in lineCode:
user.linecode = i
# 车牌号
busLicense = Bus.objects.filter(buslicense=busLicense)
for i in busLicense:
user.buslicense = i
# 趟次
user.tcnumber = tcNumber
# 每趟时间
user.tctime = tcTime
# 司机编号
userCode = Sysuser.objects.filter(code=userCode)
for i in userCode:
user.usercode = i
# 始发站
startStation = Station.objects.filter(stationname=startStation)
for i in startStation:
user.startstation = i
# 终点站
endStation = Station.objects.filter(stationname=endStation)
for i in endStation:
user.endstation = i
user.save()
return render(request,'form_basic.html',{"lineCode":all_list1,"busLicense":all_list2,"userCode":all_list3,
"startStation":all_list4,"endStation":all_list5})
def chaXun_pai_ban(request):
if request.method == 'POST':
one = request.POST.get('one')
two = request.POST.get('two')
three = request.POST.get('three')
response = Scheduling.objects.filter(code=one,tcnumber=two,tctime=three)
return render(request,'form_basic_find.html',{'schedul_list2':response})
django读取数据库转化为类文件(models.py):
from django.db import models
class Bus(models.Model):
buscode = models.AutoField(db_column='busCode', primary_key=True) # Field name made lowercase.
buslicense = models.CharField(db_column='busLicense', max_length=20) # Field name made lowercase.
bustype = models.CharField(db_column='busType', max_length=25, blank=True, null=True) # Field name made lowercase.
busstatus = models.CharField(db_column='busStatus', max_length=2, blank=True, null=True) # Field name made lowercase.
starttime = models.DateTimeField(db_column='startTime', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'bus'
class Line(models.Model):
linecode = models.AutoField(db_column='lineCode', primary_key=True) # Field name made lowercase.
linename = models.CharField(db_column='lineName', max_length=20, blank=True, null=True) # Field name made lowercase.
status = models.CharField(max_length=2, blank=True, null=True)
startlinetime = models.DateTimeField(db_column='startLineTime', blank=True, null=True) # Field name made lowercase.
direction = models.CharField(max_length=2, blank=True, null=True)
class Meta:
managed = True
db_table = 'line'
class LineStationRef(models.Model):
linecode = models.ForeignKey(Line, models.DO_NOTHING, db_column='lineCode', blank=True, null=True) # Field name made lowercase.
stationcode = models.ForeignKey('Station', models.DO_NOTHING, db_column='stationCode', blank=True, null=True) # Field name made lowercase.
stationorder = models.IntegerField(db_column='stationOrder', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'line_station_ref'
class Permission(models.Model):
permissioncode = models.AutoField(db_column='permissionCode', primary_key=True) # Field name made lowercase.
permissionname = models.CharField(db_column='permissionName', max_length=50, blank=True, null=True) # Field name made lowercase.
permissiondescribe = models.CharField(db_column='permissionDescribe', max_length=100, blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'permission'
class Role(models.Model):
rolecode = models.AutoField(db_column='roleCode', primary_key=True) # Field name made lowercase.
rolename = models.CharField(db_column='roleName', max_length=50, blank=True, null=True) # Field name made lowercase.
roledescribe = models.CharField(max_length=100, blank=True, null=True)
class Meta:
managed = True
db_table = 'role'
class RolePermissionRef(models.Model):
relationcode = models.AutoField(db_column='relationCode', primary_key=True) # Field name made lowercase.
rolecode = models.ForeignKey(Role, models.DO_NOTHING, db_column='roleCode', blank=True, null=True) # Field name made lowercase.
permissioncode = models.ForeignKey(Permission, models.DO_NOTHING, db_column='permissionCode', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'role_permission_ref'
class Scheduling(models.Model):
code = models.AutoField(primary_key=True)
linecode = models.ForeignKey(Line, models.DO_NOTHING, db_column='lineCode', blank=True, null=True) # Field name made lowercase.
tcnumber = models.CharField(db_column='tcNumber', max_length=25, blank=True, null=True) # Field name made lowercase.
tctime = models.CharField(db_column='tcTime', max_length=20, blank=True, null=True) # Field name made lowercase.
usercode = models.ForeignKey('Sysuser', models.DO_NOTHING, db_column='userCode', blank=True, null=True) # Field name made lowercase.
startstation = models.ForeignKey('Station', models.DO_NOTHING, db_column='startStation', blank=True, null=True) # Field name made lowercase.
endstation = models.ForeignKey('Station', models.DO_NOTHING, db_column='endStation', blank=True, null=True,related_name='endStation') # Field name made lowercase.
buslicense = models.ForeignKey(Bus, models.DO_NOTHING, db_column='busLicense', blank=True, null=True) # Field name made lowercase.
class Meta:
managed = True
db_table = 'scheduling'
class Station(models.Model):
stationcode = models.AutoField(db_column='stationCode', primary_key=True) # Field name made lowercase.
stationname = models.CharField(db_column='stationName', max_length=50, blank=True, null=True) # Field name made lowercase.
longitude = models.CharField(max_length=50, blank=True, null=True)
latitude = models.CharField(max_length=50, blank=True, null=True)
region = models.CharField(max_length=50, blank=True, null=True)
street = models.CharField(max_length=50, blank=True, null=True)
class Meta:
managed = True
db_table = 'station'
class Sysuser(models.Model):
code = models.AutoField(primary_key=True)
loginname = models.CharField(db_column='loginName', max_length=25, blank=True, null=True) # Field name made lowercase.
password = models.CharField(max_length=50, blank=True, null=True)
name = models.CharField(max_length=25, blank=True, null=True)
phone = models.CharField(max_length=11, blank=True, null=True)
idcard = models.CharField(db_column='idCard', max_length=25, blank=True, null=True) # Field name made lowercase.
role = models.ForeignKey(Role,models.DO_NOTHING, db_column='role', blank=True, null=True)
driving = models.DecimalField(max_digits=10, decimal_places=0, blank=True, null=True)
status = models.CharField(max_length=25, blank=True, null=True)
class Meta:
managed = True
db_table = 'sysuser'
上面就是智慧交通系统的具体演示,想要项目的可以私聊我的
qq:1657264184进行交流。之后会具体向大家讲解做过的这些项目的具体步骤。