Username already exists, when wanting to update userprofile in djago

Posted by Ajirapsy on Stack Overflow See other posts from Stack Overflow or by Ajirapsy
Published on 2012-11-16T16:58:26Z Indexed on 2012/11/16 16:59 UTC
Read the original article Hit count: 135

Filed under:

Whenever i try try to update a userprofile on djano powered web, i get the error, username already exists, please provide another one. I am trying to get it to recognize the authenticated user. ALthough every other thing works, but it would not update until i specify a new username.

views.py

@login_required
def editprofile(request):
    registeredmember = request.user.get_profile()
    if request.method == 'POST':
        userprofile_edit = RegistrationForm(request.POST, instance = registeredmember)
        if userprofile_edit.is_valid():
            userprofile_edit.save()
            return HttpResponseRedirect('/profile/')
    else:
        userprofile_edit = RegistrationForm(instance = registeredmember)
    return render_to_response('carloan/editprofile.html', {'userprofile_edit': userprofile_edit}, context_instance=RequestContext(request))

© Stack Overflow or respective owner

Related posts about django