Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

156
Views
I have this following simple view . Then why is this ValueError is coming

This is my views.py

def user_profile(request):
if request.user.is_authenticated:
    if request.method == "POST":
        fm = EditUserProfileForm(request.POST, instance=request.user)
        if fm.is_valid():
            messages.success(request,'Profile updated')
            fm.save()
        else:
            if request.user.is_superuser == True:
                fm = EditAdminProfileForm(instance = request.user)
            else:
                fm = EditUserProfileForm(instance=request.user)
        return render(request,'enroll/profile.html',{'name':request.user,'form':fm})
else:
    return HttpResponseRedirect('/login/')``

This error is coming-

Exception Type:- ValueError

Exception Value:-The view enroll.views.user_profile didn't return an HttpResponse object. It returned None instead.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You did not cover the case where request.user.is_authenticated is True, but the request.method is not a POST request:

def user_profile(request):
    if request.user.is_authenticated:
        if request.method == 'POST':
            fm = EditUserProfileForm(request.POST, instance=request.user)
            if fm.is_valid():
                messages.success(request, ‘Profile updated’)
                fm.save()
            else:
                if request.user.is_superuser == True:
                    fm = EditAdminProfileForm(instance = request.user)
                else:
                    fm = EditUserProfileForm(instance=request.user)
                return render(request, 'enroll/profile.html' ,{'name':request.user, 'form' :fm})
        else:
            # ... case not covered yet (!)
            pass
    else:
        return HttpResponseRedirect('/login/')

You thus should implement logic that will return a HttpResponse for the case with the exclamation mark (!).

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!