django的主机管理(FORM形式)

思路:

主index显示
server01 修改 删除
server02 修改 删除
server03 修改 删除

点击(修改)

templates中 修改

=======================>

urls.py

url(r'^rectify_people-(?P\d+)', views.rectify_people, name='rectify_people'),

========================>

views.py

def rectify_people(request, people_id):
**********************************************************************
      ??????????????????????????先不填

**********************************************************************
      people = models.People.objects.filter(id=people_id).first()
      return render(request, 'app01/tt.html', {'people': people})  

=====================================>

templates/app01/tt.html




    
    



{% csrf_token %}

==========================================>
又通过urls.py

url(r'^rectify_people-(?P\d+)', views.rectify_people, name='rectify_people'),

==========================================>
views.py(同上的views.py)

def rectify_people(request, people_id):
**********************************************************************
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        models.People.objects.filter(id=people_id).update(username=username, password=password)
        return redirect('/app01/')
**********************************************************************
    people = models.People.objects.filter(id=people_id).first()
    return render(request, 'app01/tt.html', {'people': people})

到此OK

你可能感兴趣的:(django的主机管理(FORM形式))