Django - How to store existing Data in Variable from Database and Update it with another variable

I am facing an issue for few days but could not get the findings to solve it. Suppose, I want to update a record into database using a form and want to keep the existing data into a variable and update it using form and keep the updated data into another variable.

Please be inform that i made a solution using session but want another way to solve it.

def client_edit(request, client_id):
 client = Client.objects.get(id=client_id)
 previous_client_name = client
 if request.method == 'POST':
    form = AddClientForm(request.POST, instance=client)
    if form.is_valid():
        client2 = form.save(commit=False)
        client2.save()
                    
        context = {
            'user': request.user,                
            'client': client2,
            'previous_client':previous_client_name,
        }
        return render(request, 'did_app/client_edit.html', context=context)
    else:            
        return render(request, 'did_app/client_edit.html', {'form': form})
 else:        
    return render(request, 'did_app/client_edit.html', {'client': client})

I tried this way but both client and previous_client return the same data.

Please suggest.

Thanks in advance

Back to Top