def role_add(request): if request.method == "POST": form = RoleListForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm() kwvars = { 'form': form, 'request': request, } return render(request, 'accounts/role_add.html', kwvars)
def role_edit(request, ids): iRole = RoleList.objects.get(id=ids) if request.method == "POST": form = RoleListForm(request.POST, instance=iRole) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('role_list')) else: form = RoleListForm(instance=iRole) kwvars = { 'ids': ids, 'form': form, 'request': request, } return render(request, 'accounts/role_edit.html', kwvars)