Example #1
0
def user_update(request, pk):
    user = get_object_or_404(ShopUser, pk=pk)
    if request.method == 'POST':
        form = AdminShopUserUpdateForm(request.POST,
                                       request.FILES,
                                       instance=user)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('myadmin:index'))
    else:
        form = AdminShopUserUpdateForm(instance=user)

    context = {'title': 'пользователи/редактирование', 'form': form}
    return render(request, 'adminapp/user_update.html', context)
Example #2
0
def user_update(request, pk):
    user = get_object_or_404(get_user_model(), pk=pk)
    if request.method == 'POST':
        user_form = AdminShopUserUpdateForm(request.POST,
                                            request.FILES,
                                            instance=user)
        if user_form.is_valid():
            user_form.save()
            return HttpResponseRedirect(reverse('myadmin:index'))
    else:
        user_form = AdminShopUserUpdateForm()

    context = {'page_title': 'пользователи/создание', 'user_form': user_form}

    return render(request, 'adminapp/user_update.html', context)