コード例 #1
0
def permission_add(request):
    if request.method == "POST":
        form = PermissionListForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('permission_list'))
    else:
        form = PermissionListForm()

    kwvars = {
        'form': form,
        'request': request,
    }
    return render(request, 'accounts/permission_add.html', kwvars)
コード例 #2
0
def permission_edit(request, ids):
    iPermission = PermissionList.objects.get(id=ids)
    if request.method == "POST":
        form = PermissionListForm(request.POST, instance=iPermission)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('permission_list'))
    else:
        form = PermissionListForm(instance=iPermission)

    kwvars = {
        'ids': ids,
        'form': form,
        'request': request,
    }
    return render(request, 'accounts/permission_edit.html', kwvars)