车主信息

1. 创建customer页面

2.urls新增地址

3.views增加方法

4.怎样获取model的字段名?

def detail(request):
# types = User_detail.objects.all()
# context = {'types': types}
# print(User_detail.objects.all())
model_obj = get_model('customer','User_detail')
typedict = {}
for types in model_obj._meta.fields:
typedict[types.name] = types.verbose_name
    return render(request, 'customer.html',{'typedict':typedict})
<tr>
<th>
<input type="checkbox" name="" checked=""> 全选
</th>
<th>
{{ typedict.user_name}}
</th>
<th>
{{ typedict.car_no}}
</th>
<th>
{{ typedict.phone}}
</th>
<th>
{{ typedict.create_time}}
</th>

猜你喜欢

转载自www.cnblogs.com/putinsong/p/10528983.html