我想通过输入类型“text”将多个数据添加到数据库,如下面的代码
<input type="text" name= "searchmemberTaskMore" id= "{{username}}" class="btn btn-default" value="{{username}}"/>'
view.py
def addMemberTask(request,project_url):
dictData = getInitialVariable(request)
if "POST" in request.method:
if request.POST['taskSelectedAddmeberMore'] != "":
taskSelectedAddmeberMore = request.POST['taskSelectedAddmeberMore']
if request.POST['searchmemberTaskMore'] != "":
searchmemberTaskMore = request.POST['searchmemberTaskMore']
if request.POST['taskSelectedAddmeberMoreID'] != "":
taskSelectedAddmeberMoreID = request.POST['taskSelectedAddmeberMoreID']
object_project = projects.objects.filter(user__id=dictData["USER"].id)[0]
object_project = projects.objects.filter(user__id=dictData["USER"].id)[0]
t = tasks.objects.filter(id=taskSelectedAddmeberMoreID)[0]
u = User.objects.filter(username=searchmemberTaskMore)[0]
t.user.add(u)
return HttpResponseRedirect('/projectDetail/'+project_url)
我应该如何解决问题?
谢谢。