[Answered ]-How to update user details in custom user model in django

1👍

Yh, you’ll get that error because the update method is available for only querysets.
So you can do this:


def editPlacementManager(request):

    if request.method=='POST':
        name=request.POST.get('name')
        phone=request.POST.get('phone')
        email=request.POST.get('email')
        password=request.POST.get('password')
        userid = request.POST.get('pmId')

        user = User.objects.get(id=userid)
        user.name = name
        user.phone = phone
        user.email = email
        # You can continue with whichever field you want
        user.save()
        # Then finally you save the object with the updated fields
        

        return redirect('listplacementmanager')
    return render(request,"index/placementmanager.html")

0👍

actually it’s a simple thing just hash the password and update.

👤Bakugo

Leave a comment