html – How can I allow users to update details? I am getting NOT NULL constraint failed


from django.contrib.auth.signals import user_logged_in
from django.shortcuts import redirect, render
from django.contrib.auth.models import User,auth
from django.contrib.auth import authenticate,logout
from django.contrib import messages
from django.contrib.auth.decorators import login_required





@login_required
def update(request):
    if request.method=="POST":
        firstname=request.POST.get('first_name')
        lastname=request.POST.get('last_name')
        """email=request.POST.get('email')
        username=request.POST.get('username')"""
        #password=request.POST.get('password')
        cur=request.user
        print(cur)
        print('i came till here')
        user=User.objects.filter(username=cur).update(first_name=firstname,last_name=lastname)
        user.save()
        print('i came here')
        return redirect('profile')
    else:
        print('i came to elses block')
        redirect('index')

I want users to update their details but I am getting error when I try to submit “Not null constraint”
The problem is only in the update function. Any help will be appreciated.



Source link

Latest articles

Related articles

Leave a reply

Please enter your comment!
Please enter your name here