Django edit form based on add form?

后端 未结 2 613
渐次进展
渐次进展 2020-11-28 01:44

I\'ve made a nice form, and a big complicated \'add\' function for handling it. It starts like this...

def add(req):
    if req.method == \'POST\':
        f         


        
2条回答
  •  粉色の甜心
    2020-11-28 02:24

    You can have hidden ID field in form and for edit form it will be passed with the form for add form you can set it in req.POST e.g.

    formData =  req.POST.copy()
    formData['id'] = getNewID()
    

    and pass that formData to form

提交回复
热议问题