You haven't accounted for a GET
scenario; what happens when the view is not accessed via POST
? You return nothing, therefore you get this error.
Return an http.HttpResponse
when request.method != 'POST'
Perhaps you meant to un-indent the bottom half else
statement.
You haven't accounted for a GET
scenario; what happens when the view is not accessed via POST
? You return nothing, therefore you get this error.
Return an http.HttpResponse
when request.method != 'POST'
Perhaps you meant to un-indent the bottom half else
statement.
@login_required
def user_profile(request):
if request.method == 'POST':
form = UserProfileForm(request.POST, instance=request.user.profile)
if form.is_valid():
form.save()
return HttpResponseRedirect('/accounts/loggedin')
else:
user = request.user
profile = user.profile
form = UserProfileForm(instance=profile)
args = {}
args.update(csrf(request))
args['form'] = form
return render(request, 'profile.tml', args)