Hello everyone,
I want to update a field on database but,
get_sample.columnDataName = request.POST.get(‘textarea’) line below gives an error. It is obviously because of columnDataName parameter which holds a string data. How can I fix it dinamically? Thank you in advance.
views.py
def edit_column(request):
if request.method == "POST":
nplainArray = request.POST.getlist('nplainArray[]')
columnDataName = request.POST.get('columnDataName')
updateText = request.POST.get('textarea')
for value in nplainArray:
get_sample = Samples.objects.get(id=value)
if get_sample != None:
get_sample.columnDataName = request.POST.get('textarea')
get_sample.save()
messages.success(request, "Column data is updated successfully!")
return HttpResponseRedirect("/")