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)
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)