我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用django.shortcuts.HttpResponseRedirect()。
def update_profile(request, user_id): # ???????? user_data = models.UserProfile.objects.get(id=user_id) departments = models.Departments.objects.all() if request.method == 'POST' and request.POST: print request.POST print request.FILES username = user_data.username user_data.departments_id = request.POST['departments'] user_data.nickname = request.POST['nickname'] user_data.email = request.POST['email'] user_data.phone = request.POST['phone'] if request.FILES: user_data.headimg = upload_file(username, request.FILES['headimg']) else: print 'headimg??' user_data.save() return HttpResponseRedirect('/web/user/profile/%d' % int(user_id)) return render(request, 'update-profile.html', locals())
def register_team(request): if request.method == 'GET': team_form = TeamCreationForm() team_member_formset = TeamMemberCreationFormSet() elif request.method == 'POST': team_form = TeamCreationForm(request.POST) team_member_formset = TeamMemberCreationFormSet(request.POST) if team_form.is_valid() and team_member_formset.is_valid(): t = team_form.save() for form in team_member_formset: tm = form.save(commit=False) # Set foreignkey to team tm.team = t tm.save() return HttpResponseRedirect(reverse('teams:login')) return render(request, 'teams/register.html', { 'team_form': team_form, 'team_member_formset': team_member_formset,} )
def app_add(request): if request.method == 'POST': form = AppAddForm(request.POST) if form.is_valid(): if not App.objects.filter(app_domain=form.cleaned_data['app_name']): f = form.save(commit=False) f.app_key = random_str() f.save() messages.add_message(request, messages.SUCCESS, '??????') return HttpResponseRedirect(reverse('app:app_list')) messages.add_message(request, messages.ERROR, '???????????????') messages.add_message(request, messages.ERROR, 'ERROR: ' + re.compile(r'<[^>]+>', re.S).sub('', str(form.errors))) return HttpResponseRedirect(reverse('app:app_add')) else: data = Policy.objects.all() return render_to_response('app/list.html', {'data': data}, context_instance=RequestContext(request))
def app_edit(request): if request.method == 'POST': msg = '????' form = AppEditForm(request.POST) if form.is_valid() and App.objects.filter(app_id=form.cleaned_data['app_id']): f = form.save(commit=False) f.app_id = form.cleaned_data['app_id'] f.app_key = App.objects.get(pk=form.cleaned_data['app_id']).app_key f.save() else: msg = '??????????!' messages.add_message(request, messages.INFO, msg) return HttpResponseRedirect(reverse('app:app_list')) else: messages.add_message(request, messages.ERROR, '??????') return HttpResponseRedirect(reverse('app:app_list'))
def user_add(request): form = UsersAddForm(request.POST) message_error = True msg = '??????' if form.is_valid(): if not Users.objects.filter(users_name=form.cleaned_data['users_name']): m2 = hashlib.md5() m2.update(form.cleaned_data['users_password']) f = form.save(commit=False) f.users_password = m2.hexdigest() f.users_create_time = datetime.now() f.users_otp = pyotp.random_base32() f.save() msg = '????' message_error = False else: msg = 'ERROR: ' + re.compile(r'<[^>]+>', re.S).sub('', str(form.errors)) if message_error: messages.add_message(request, messages.ERROR, msg) return HttpResponseRedirect(reverse('users:user_add')) else: messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('users:user_list'))
def user_edit(request): users_name = request.REQUEST.get('users_name') if request.method == 'POST' and users_name: message_error, msg = True, '?????' try: u = Users.objects.get(pk=users_name) form_data = UsersEditForm(request.POST or None, instance=u) if form_data.is_valid(): cd = form_data.cleaned_data f = form_data.save(commit=False) if form_data['users_password']: m2 = hashlib.md5() m2.update(cd['users_password']) f.users_password = m2.hexdigest() f.save() message_error, msg = False, '??????!' else: msg = re.compile(r'<[^>]+>', re.S).sub('', str(form_data.errors)) except Users.DoesNotExist: msg = '?????!' # ???? render_message(request, message_error, msg) return HttpResponseRedirect(reverse('users:user_list'))
def user_active(request, users_name): if users_name: try: users = Users.objects.get(users_name=users_name) if users.users_active == 1: users.users_active = 0 msg = '???????' else: users.users_active = 1 msg = '???????' users.save() messages.add_message(request, messages.SUCCESS, msg) except Users.DoesNotExist: msg = '??????' messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('users:user_list'))
def policy_add(request): if request.method == 'POST': form = PolicyAddForm(request.POST) message_error, msg = True, '??????' if form.is_valid(): if form.cleaned_data['policy_default'] == 1 and Policy.objects.filter(policy_default=1): msg = '??????????????????' else: if not Policy.objects.filter(policy_name=form.cleaned_data['policy_name']): f = form.save(commit=False) f.save() message_error, msg = False, '??????' else: msg = '???????????' else: msg = '??????: ' + re.compile(r'<[^>]+>', re.S).sub('', str(form.errors)) render_message(request, message_error, msg) return HttpResponseRedirect(reverse('policy:policy_list'))
def policy_rule_add(request, rule_policy): if request.method == 'POST': form = PolicyRuleAddForm(request.POST) if form.is_valid(): if not PolicyRule.objects.filter(rule_policy=rule_policy).filter( rule_value=form.cleaned_data['rule_value']): f = form.save(commit=False) f.save() messages.add_message(request, messages.SUCCESS, '??????') return HttpResponseRedirect(reverse('policy:policy_rule_list', args=[rule_policy])) messages.add_message(request, messages.ERROR, '???????????????') messages.add_message(request, messages.ERROR, 'ERROR: ' + re.compile(r'<[^>]+>', re.S).sub('', str(form.errors))) return HttpResponseRedirect(reverse('policy:policy_rule_list', args=[rule_policy])) else: return render_to_response('policy/rule/list.html', {'rule_policy': rule_policy}, context_instance=RequestContext(request))
def policy_rule_edit(request, policy_id): if request.method == 'POST': msg = '????' form = PolicyRuleEditForm(request.POST) if form.is_valid(): if PolicyRule.objects.filter(rule_id=form.cleaned_data["rule_id"]): f = form.save(commit=False) f.rule_id = form.cleaned_data["rule_id"] f.save() else: msg = '?????!' messages.add_message(request, messages.INFO, msg) else: msg = 'ERROR: ' + re.compile(r'<[^>]+>', re.S).sub('', str(form.errors)) messages.add_message(request, messages.ERROR, msg) return HttpResponseRedirect(reverse('policy:policy_rule_list', args=[policy_id])) else: messages.add_message(request, messages.ERROR, '?????') return HttpResponseRedirect(reverse('policy:policy_rule_list', args=[policy_id]))
def acc_login(request): if request.method == "POST": username = request.POST.get('email') password = request.POST.get('password') user = auth.authenticate(username=username, password=password) if user: # if timezone.now() > user.valid_begin_time and timezone.now() < user.valid_end_time: if user.valid_begin_time < timezone.now() < user.valid_end_time: auth.login(request, user) request.session.set_expiry(60*30) # print 'session expires at :',request.session.get_expiry_date() return HttpResponseRedirect('/') else: return render(request, 'login.html', { 'login_err': 'User account is expired,please contact your IT guy for this!' }) else: return render(request, 'login.html', { 'login_err': 'Wrong username or password!' }) else: return render(request, 'login.html')
def home(request): """ Generates the homepage for the app, using homepage.html """ context = {} res = None if request.method == 'GET': form = HomePage(request.GET) if form.is_valid(): if form.cleaned_data['start_quiz']: return HttpResponseRedirect('quiz_form') print (context) #create dictionary for text displayed on homepage context['explanation_text'] = 'Our 11 question quiz will determine \ your investor profile, and then recommend an investment portfolio that \ matches your needs' context['error_message'] = 'Each field is Required!' context['form'] = form return render(request, 'homepage.html', context)
def login(request): #??????? if request.method=="POST": #?????username name = request.POST.get("username") #????? db,cursor = connect() #??sql?????? # print len(name.encode('gbk')) sql = "select username from user" cursor.execute(sql) # print cursor.execute(sql) for row in cursor.fetchall(): # print len(row[0]) #?????????? if name.encode('gbk')==row[0]: return HttpResponseRedirect("/index/index/%s" % name) #???fanhuilogin??sta??? return render_to_response("login.html",{ 'error':"???????????????", }) #???????? else: return render_to_response("login.html",{ })
def user_del(request): if request.method == 'GET': userauth = request.COOKIES.get('user_auths','') ids = request.GET.getlist('id') if ids != '': idstring = ','.join(ids) temp = idstring[0:-1] try: #result = models.UserLogin.objects.filter(login_name__user_hash=userauth) models.UserLogin.objects.extra(where=['id IN ('+temp+')']).delete() response = HttpResponseRedirect("/user/log/1/") return response except Exception as e: response = HttpResponseRedirect("/user/log/1/") return response else: response = HttpResponseRedirect("/user/log/1/") return response else: response = HttpResponseRedirect("user/log/1/") return response
def edit(request,topic_id): try: topic = Topic.objects.get(id=topic_id) if topic.author != request.user: raise Http404 except Node.DoesNotExist: raise Http404 if request.method == 'POST': form = TopicForm(request.POST) if form.is_valid(): topic.title = form.clean()['title'] topic.content = form.clean()['content'] topic.updated_on = timezone.now() topic.save() return HttpResponseRedirect(reverse("bbs:topic" ,args=(topic.id,))) else: form = TopicForm(instance=topic) return render(request,'bbs/edit.html',{'topic':topic,'form':form})
def fav_topic(request, topic_id): if request.method == "GET": return HttpResponseRedirect(reverse("bbs:index")) try: topic = Topic.objects.get(pk=topic_id) if FavoritedTopic.objects.filter(user=request.user, topic=topic).first(): messages.error(request, u"???????") return HttpResponseRedirect(reverse("bbs:index")) fav_topic_new = FavoritedTopic.objects.create(user=request.user, topic=topic) fav_topic_new.save() except Topic.DoesNotExist: messages.error(request, u"?????") return HttpResponseRedirect(reverse("bbs:index")) #except IntegrityError: #messages.error(request, u"???????") #return HttpResponseRedirect(reverse("bbs:index")) return HttpResponseRedirect(reverse("bbs:topic" ,args=(topic_id,)))
def appowner_add(request): temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = AppOwnerForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('appowner_list')) else: form = AppOwnerForm() results = { 'form': form, 'request': request, 'temp_name': temp_name, 'page_type': "whole" } return render(request, 'appconf/appowner_add_edit.html', results)
def appowner_edit(request, appowner_id, mini=False): appowner = AppOwner.objects.get(id=appowner_id) temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = AppOwnerForm(request.POST, instance=appowner) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('appowner_list')) else: form = AppOwnerForm(instance=appowner) results = { 'form': form, 'appowner_id': appowner_id, 'request': request, 'temp_name': temp_name, 'page_type': "whole" } return render(request, 'appconf/appowner_add_edit.html', results)
def project_add(request): temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = ProjectForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('project_list')) else: form = ProjectForm() results = { 'form': form, 'request': request, 'temp_name': temp_name, } return render(request, 'appconf/project_base.html', results)
def product_add(request): temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = ProductForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('product_list')) else: form = ProductForm() results = { 'form': form, 'request': request, 'temp_name': temp_name, } return render(request, 'appconf/product_base.html', results)
def product_edit(request, product_id): product = Product.objects.get(id=product_id) temp_name = "appconf/appconf-header.html" if request.method == 'POST': form = ProductForm(request.POST, instance=product) if form.is_valid(): form.save() return HttpResponseRedirect(reverse('product_list')) else: form = ProductForm(instance=product) results = { 'form': form, 'product_id': product_id, 'request': request, 'temp_name': temp_name, } return render(request, 'appconf/product_base.html', results)
def login(request): if request.user.is_authenticated(): return HttpResponseRedirect('/') if request.method == 'GET' and request.GET.has_key('next'): next_page = request.GET['next'] else: next_page = '/' if next_page == "/accounts/logout/": next_page = '/' if request.method == "POST": form = LoginUserForm(request, data=request.POST) if form.is_valid(): auth.login(request, form.get_user()) return HttpResponseRedirect(request.POST['next']) else: form = LoginUserForm(request) kwargs = { 'request': request, 'form': form, 'next': next_page, } return render(request, 'accounts/login.html', kwargs)
def login(request): # ???? if request.method == 'POST' and request.POST: # ????????????? username = request.POST['username'] password = request.POST['password'] # print request.POST # ????????? if user_valid(username): data = models.UserProfile.objects.get(username=username) # ???????? print data.password password = hash_sha256(password, username) print password if password == data.password: # ?????? response = HttpResponseRedirect("/web/") # ?????response?? # response.set_cookie("username", username) # cookie ?????cookie request.session['username'] = username # ??session return response # ???? else: # ?????? return HttpResponseRedirect("/web/login") else: # ??????? return HttpResponseRedirect("/web/login") else: # ????????????????? return render(request, "login.html", locals())
def alter_permisson(request, user_id): # ????????? user = models.UserProfile.objects.get(id=user_id) if request.method == 'POST' and request.POST: print dict(request.POST) permissions = models.Permission.objects.all() try: new_permissions = dict(request.POST)['permission'] # ??????????????????????????? except: for i in permissions: permission = models.Permission.objects.get(id=i.id) user.permission.remove(permission) else: new_permissions = dict(request.POST)['permission'] new_permissions = [int(i) for i in new_permissions] for i in permissions: if i.id in new_permissions: permission = models.Permission.objects.get(id=i.id) user.permission.add(permission) else: permission = models.Permission.objects.get(id=i.id) user.permission.remove(permission) return HttpResponseRedirect('/web/view/user/list/')
def alter_group_permisson(request, group_id): # ????????? group = models.GroupProfile.objects.get(id=group_id) if request.method == 'POST' and request.POST: print dict(request.POST) permissions = models.Permission.objects.all() try: new_permissions = dict(request.POST)['permission'] # ?????????????????????????? except: for i in permissions: permission = models.Permission.objects.get(id=i.id) group.permission.remove(permission) else: new_permissions = dict(request.POST)['permission'] new_permissions = [int(i) for i in new_permissions] for i in permissions: if i.id in new_permissions: permission = models.Permission.objects.get(id=i.id) group.permission.add(permission) else: permission = models.Permission.objects.get(id=i.id) group.permission.remove(permission) return HttpResponseRedirect('/web/view/group/')
def server_register(request): # ???????? departments = models.Departments.objects.all() if request.method == 'POST' and request.POST: server = models.Servers() server.hostname = request.POST['hostname'] server.ip = request.POST['ip'] server.mac = request.POST['mac'] server.cpu = request.POST['cpu'] server.mainboard = request.POST['mainboard'] server.mem = request.POST['mem'] server.disk = request.POST['disk'] server.system = request.POST['system'] server.is_active = request.POST['is_active'] server.departments_id = request.POST['departments'] server.save() new_server = models.Servers.objects.get(hostname=request.POST['hostname']) if new_server: print new_server.id print new_server.hostname return render(request, 'server-register.html', locals()) else: return HttpResponseRedirect('/web/server/register/') else: return render(request, 'server-register.html', locals())
def server_update(request, server_id): # ???????? departments = models.Departments.objects.all() server_data = models.Servers.objects.get(id=server_id) if request.method == 'POST' and request.POST: server = models.Servers.objects.get(id=server_id) server.hostname = request.POST['hostname'] server.ip = request.POST['ip'] server.mac = request.POST['mac'] server.cpu = request.POST['cpu'] server.mainboard = request.POST['mainboard'] server.mem = request.POST['mem'] server.disk = request.POST['disk'] server.system = request.POST['system'] server.is_active = request.POST['is_active'] server.departments_id = request.POST['departments'] server.save() return HttpResponseRedirect('/web/servers/%d' % int(server_id)) else: return render(request, 'server-update.html', locals())
def customer_detail(request,customer_id): print(customer_id) customer_obj=models.Customer.objects.get(id=customer_id) if request.method == "POST": form = forms.CustomerModel(request.POST,instance=customer_obj) print('errorsucc-->',form.errors) if form.is_valid(): # ???????,????????,?????????modelform form.save() base_url = '/'.join(request.path.split('/')[:-2]) print('error-->',form.errors) return HttpResponseRedirect(base_url) else: form=forms.CustomerModel(instance=customer_obj) print('url',request.path) base_url='/'.join(request.path.split('/')[:-2]) print('base_url',base_url) print('errorsucc-->', form.errors) return render(request,'crm/customer_detail.html',{'customer_form':form})
def customer_detail(request,customer_id): print(customer_id) customer_obj=models.Customer.objects.get(id=customer_id) if request.method == "POST": form = forms.CustomerModel(request.POST,instance=customer_obj) print(request.POST) # ??POST????? print('errorsucc-->',form.errors) if form.is_valid(): # ???????,????????,?????????modelform form.save() base_url = '/'.join(request.path.split('/')[:-2]) print('error-->',form.errors) return HttpResponseRedirect(base_url) else: form=forms.CustomerModel(instance=customer_obj) print('url',request.path) base_url='/'.join(request.path.split('/')[:-2]) print('base_url',base_url) print('errorsucc-->', form.errors) return render(request,'crm/customer_detail.html',{'customer_form':form})
def app_key_reset(request, app_id): try: data = App.objects.get(pk=app_id) data.app_key = random_str() data.save() messages.add_message(request, messages.SUCCESS, 'key?????') except App.DoesNotExist: messages.add_message(request, messages.ERROR, '??????') return HttpResponseRedirect(reverse('app:app_list'))
def app_del(request, app_id): try: App.objects.get(pk=app_id).delete() messages.add_message(request, messages.SUCCESS, '????') except App.DoesNotExist: messages.add_message(request, messages.ERROR, '??????????') return HttpResponseRedirect(reverse('app:app_list'))
def registry(request): if request.method == 'POST': form = UserRegistryForm(request.POST) message_error = True msg = '??????' if form.is_valid(): cd = form.cleaned_data # ???????? if cd['users_password1'] == cd['users_password2'] and len(cd['users_password1']) < 6: msg = '?????????????6?!' else: user = Users.objects.filter(users_name=cd['users_name']) if not user: m2 = hashlib.md5() m2.update(cd['users_password1']) Users(users_name=cd['users_name'], users_password=m2.hexdigest(), users_create_time=datetime.now(), users_last_login=datetime.now(), users_otp=pyotp.random_base32()).save() msg = '????' message_error = False else: msg = '????: ????????!' if message_error: messages.add_message(request, messages.ERROR, msg) return HttpResponseRedirect(reverse('users:user_registry')) else: messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('nav')) else: return render_to_response('users/register.html', {}, context_instance=RequestContext(request))
def user_del(request, users_name): if users_name: try: users = Users.objects.get(users_name=users_name) msg = '???????' messages.add_message(request, messages.SUCCESS, msg) users.delete() except Users.DoesNotExist: msg = '??????' messages.add_message(request, messages.SUCCESS, msg) return HttpResponseRedirect(reverse('users:user_list'))
def policy_del(request, policy_id): try: p = Policy.objects.get(pk=policy_id) # del rule PolicyRule.objects.filter(rule_policy=p.policy_id).delete() p.delete() messages.add_message(request, messages.SUCCESS, '??????') except Policy.DoesNotExist: messages.add_message(request, messages.ERROR, '??????????') return HttpResponseRedirect(reverse('policy:policy_list'))
def policy_disable(request, policy_id): try: p = Policy.objects.get(pk=policy_id) p.policy_active = 2 p.save() messages.add_message(request, messages.SUCCESS, '??????') except Policy.DoesNotExist: messages.add_message(request, messages.ERROR, '??????????') return HttpResponseRedirect(reverse('policy:policy_list'))
def policy_active(request, policy_id): try: p = Policy.objects.get(pk=policy_id) p.policy_active = 1 p.save() messages.add_message(request, messages.SUCCESS, '??????') except Policy.DoesNotExist: messages.add_message(request, messages.ERROR, '??????????') return HttpResponseRedirect(reverse('policy:policy_list'))
def logout_view(request): logout(request) return HttpResponseRedirect('/accounts/login/')
def acc_logout(request): logout(request) return HttpResponseRedirect("/login")
def acc_logout(request): logout(request) return HttpResponseRedirect('/')
def acc_login(request): if request.method == 'GET': # ???GET????????? return render(request, 'login.html', locals()) elif request.method == 'POST': username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) # ???????????user??????None if user: login(request, user) # ??????user???request # print(request) return HttpResponseRedirect('/') else: login_err = 'Username or Password error!' return render(request, 'login.html', locals()) # ???????????
def search(request): """ Search view """ if "q" in request.GET: queries = request.GET['q'].split() projects = [] for q in queries: projects.extend(list(Project.objects.filter( Q(name__icontains=q) | Q(description__icontains=q) | Q(short_description__icontains=q)))) for lang in Language.objects.filter(name__icontains=q): for project in lang.project_set.all(): projects.append(project) for platform in Platform.objects.filter(name__icontains=q): for project in platform.project_set.all(): projects.append(project) try: # If a number is given, include the project with that ID if any q = int(q) projects.append(Project.objects.get(id=q)) except: pass projects = set(projects) context = { 'projects': list(projects), } return render(request, 'search_page.html', context) else: return HttpResponseRedirect("/")
def login_user(request): if request.method == "POST": username = request.POST['username'] password = request.POST['password'] user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect(reverse('calendar')) else: return render(request, 'login/login.html', {'error_message': 'Your account has been disabled'}) else: return render(request, 'login/login.html', {'error_message': 'Invalid login'}) return render(request, 'login/login.html')
def register(request): obj_R = RegisterForm() retR = {'dataR':None,'errorR':''} retR['dataR'] = obj_R if request.method == 'POST': checkform = RegisterForm(request.POST) checkresult = checkform.is_valid() if checkresult: Addr = request.META['REMOTE_ADDR'] Agent = request.META['HTTP_USER_AGENT'] Register_date = str(time.strftime("%Y-%m-%d %H:%M:%S",time.localtime())) #print request.POST Username = request.POST.get('username','') Password = request.POST.get('password','') Email = request.POST.get('email','') Phone = request.POST.get('phone','') G = models.UserGroup.objects.get(gname="user") key = 48 result = models.UserInfo.objects.create(username = Username,password = encrypt(key, Password),email = Email,phone = Phone,ip = Addr,agent = Agent,register_date = Register_date,permiss = G ) if result: return HttpResponseRedirect('/') else: raise Http404("Register is fail") else: errorMsg = checkform.errors firstErrorMsg = checkform.errors.as_data().values()[0][0].messages[0] retR['errorR'] = firstErrorMsg return render_to_response('user/register_index.html', retR)
def auth_fail_handler(request): return HttpResponseRedirect("/") #password add encrypt
def get(self, request): return HttpResponseRedirect(FB_CLIENT.redirect_url)
def notice_delete(request, notice_id): if request.method == 'GET': try: notice = Notice.objects.get(id=notice_id) except Notice.DoesNotExist: raise Http404 notice.is_deleted = True notice.save() return HttpResponseRedirect(reverse("bbs:notice"))
def unfav_topic(request, topic_id): if request.method == "GET": return HttpResponseRedirect(reverse("bbs:index")) try: topic = Topic.objects.get(pk=topic_id) faved_topic = FavoritedTopic.objects.filter(user=request.user, topic=topic) faved_topic.delete() except Topic.DoesNotExist: messages.error(request, u"?????") return HttpResponseRedirect(reverse("bbs:index")) return HttpResponseRedirect(reverse("bbs:topic", args=(topic_id,)))
def appowner_del(request): appowner_id = request.GET.get('id', '') if appowner_id: AppOwner.objects.filter(id=appowner_id).delete() appowner_id_all = str(request.POST.get('appowner_id_all', '')) if appowner_id_all: for appowner_id in appowner_id_all.split(','): AppOwner.objects.filter(id=appowner_id).delete() return HttpResponseRedirect(reverse('appowner_list'))
def project_del(request): project_id = request.GET.get('project_id', '') if project_id: Project.objects.filter(id=project_id).delete() project_id_all = str(request.POST.get('project_id_all', '')) if project_id_all: for project_id in project_id_all.split(','): Project.objects.filter(id=project_id).delete() return HttpResponseRedirect(reverse('project_list'))