示例#1
0
def edit_profile(request):
    if request.method == 'POST':
        form = EditProfile(request.POST, instance=request.user)
        if form.is_valid():
            form.save()
            return redirect('accounts:profile')
    else:
        form = EditProfile(instance=request.user)
        args = {'form': form}
        return render(request, 'accounts/edit.html', args)
示例#2
0
def edit_new_profile(request):
    if request.method == 'POST':
        form = EditProfile(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            return redirect(reverse('accounts:view_profile'))
    else:
        form = EditProfile(instance=request.user)
    return render(request, 'accounts/edit_profile.html', {'form': form})
def editprofile(request):

    args = {}

    if request.method == 'POST':
        form = EditProfile(request.POST, instance=request.user)

        if form.is_valid():
            form.save()
            messages.success(request, 'Your profile has been updated.')
            return redirect('editprofile')

        messages.error(request, 'You must complete required fields')
        return redirect('editprofile')

    form = EditProfile(instance=request.user)
    args['form'] = form

    return render(request, 'accounts/editprofile.html', args)