[Answer]-Django Error local variable 'Person' referenced before assignment

1👍

Try to put Person at the top of request.user.is_authenticated. And you forgot to put ‘()’ in get_profile

@login_required     
def Profile(request):
    Person = request.user.get_profile()
    if not request.user.is_authenticated():
        return HttpResponseRedirect('/login/')
    return render_to_response('profile.html', {
        'Person': Person
     }, context_instance=RequestContext(request))

Leave a comment