django.shortcuts.HttpResponseRedirect - python examples

Here are the examples of the python api django.shortcuts.HttpResponseRedirect taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

93 Examples 7

3 View Complete Implementation : region.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def region_del(request):
    region_id = request.GET.get('id', '')
    if region_id:
        Region.objects.filter(id=region_id).delete()

    region_id_all = str(request.POST.get('region_id_all', ''))
    if region_id_all:
        for region_id in region_id_all.split(','):
            Region.objects.filter(id=region_id).delete()

    return HttpResponseRedirect(reverse('region_list'))

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : jimmy201602
    def form_valid(self, form):
        username = form.cleaned_data['user']
        pastword = form.cleaned_data['newpastword1']
        email = form.cleaned_data['email']
        User.objects.create_user(
            username=username, email=email, pastword=pastword, is_active=True, is_staff=True)
        return HttpResponseRedirect(self.get_success_url())

3 View Complete Implementation : user.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
def change_pastword(request):
    if request.method == 'POST':
        form = ChangePastwordForm(user=request.user, data=request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('user_list'))
    else:
        form = ChangePastwordForm(user=request.user)
    kwargs = {
        'form': form,
        'request': request,
    }
    return render(request, 'accounts/change_pastword.html', kwargs)

3 View Complete Implementation : project.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def project_edit(request, project_id):
    project = Project.objects.get(id=project_id)
    if request.method == 'POST':
        form = ProjectForm(request.POST, instance=project)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('project_list'))
    else:
        form = ProjectForm(instance=project)

    results = {
        'form': form,
        'project_id': project_id,
        'request': request,
    }
    return render(request, 'appconf/project_base.html', results)

3 View Complete Implementation : appowner.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def appowner_edit(request, appowner_id, mini=False):
    appowner = AppOwner.objects.get(id=appowner_id)
    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,
        'page_type': "whole"
    }
    return render(request, 'appconf/appowner_add_edit.html', results)

3 View Complete Implementation : views.py
Copyright GNU General Public License v2.0
Author : geekwolf
@login_required
@permission_required('content.del_type', raise_exception=True)
def type_del(request, id):
    if id:
        Content.objects.filter(type_id=id).update(type_id=None)
        Type.objects.filter(id=id).delete()
    return HttpResponseRedirect(reverse('type_add'))

3 View Complete Implementation : resource.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def resource_add(request):
    if request.method == 'POST':
        form = ResourceForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('resource_list'))
    else:
        form = ResourceForm()

    results = {
        'form': form,
        'request': request,
    }
    return render(request, 'branches/resource_base.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, cid):
    if not request.user.is_authenticated:
      messages.error(request, "请先登录。")
    else:
      invitation_code = request.POST.get('code', '')
      try:
        invitation = ContestInvitation.objects.get(code=invitation_code)
        add_participant_with_invitation(cid, invitation.pk, request.user)
        messages.success(request, "你已成功加入。")
      except ContestInvitation.DoesNotExist:
        messages.error(request, "邀请码有误。")
    return HttpResponseRedirect(reverse('contest:dashboard', kwargs={'cid': cid}))

3 View Complete Implementation : views.py
Copyright GNU General Public License v2.0
Author : welliamcao
    @method_decorator_adaptor(permission_required, "astet.astets_add_astets","/403/")   
    def post(self, request, *args, **kwagrs):
        f = request.FILES.get('import_file')
        filename = os.path.join(os.getcwd() + '/upload/',f.name)
        if os.path.isdir(os.path.dirname(filename)) is not True:os.makedirs(os.path.dirname(filename))
        fobj = open(filename,'wb')
        for chrunk in f.chunks():
            fobj.write(chrunk)
        fobj.close()
        res = self.import_astets(filename)
        if isinstance(res, str):return JsonResponse({'msg':res,"code":500,'data':[]})
        return HttpResponseRedirect('/user/center/')       

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk):
    try:
      comments = [''] * int(request.POST['number'])
    except KeyError:
      comments = list(filter(lambda x: x, map(lambda x: x.strip(), request.POST['list'].split('\n'))))
    contest = Contest.objects.get(pk=pk)
    self._create(contest, comments)
    return HttpResponseRedirect(request.POST['next'])

3 View Complete Implementation : project.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def project_del(request):
    project_id = request.GET.get('id', '')
    if project_id:
        Project.objects.filter(id=project_id).delete()

    if request.method == 'POST':
        project_items = request.POST.getlist('g_check', [])
        if project_items:
            for n in project_items:
                Project.objects.filter(id=n).delete()
    # all_product = Project.objects.all()
    return HttpResponseRedirect(reverse('project_list'))

3 View Complete Implementation : authinfo.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def authinfo_add(request):
    if request.method == 'POST':
        form = AuthInfoForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('authinfo_list'))
    else:
        form = AuthInfoForm()

    results = {
        'form': form,
        'request': request,
        'page_type': "whole"
    }
    return render(request, 'appconf/authinfo_add_edit.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : fengjinqi
def getClbackQQ(request):
    """
    获取授权回调地址
    :param request:
    :return:
    """
    next= request.GET.get('next','')
    state = str(random.randrange(100000, 999999))  # 定义一个随机状态码,防止跨域伪造攻击。
    request.session['state'] = state  # 将随机状态码存入Session,用于授权信息返回时验证。
    request.session['next']=next
    client_id = '101532677'  # QQ互联中网站应用的APP ID。
    callback = parse.urlencode({'redirect_uri': 'https://www.fengjinqi.com/callbackget'})
    # 对回调地址进行编码,用户同意授权后将调用此链接。
    login_url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%s&%s&state=%s&next=%s' % (
        client_id, callback, state,next)  # 组织QQ第三方登录链接
    return HttpResponseRedirect(login_url)  # 重定向到QQ第三方登录授权页面

3 View Complete Implementation : branch.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def branch_add(request):
    if request.method == 'POST':
        form = BranchForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('branch_list'))
    else:
        form = BranchForm()

    results = {
        'form': form,
        'request': request,
    }
    return render(request, 'branches/branch_base.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def form_valid(self, form):
    instance = form.save(commit=False)
    instance.author = self.request.user
    instance.save()
    instance.revisions.create(satle=instance.satle, text=instance.text, author=self.request.user)
    return HttpResponseRedirect(reverse('blog:index', kwargs={'pk': self.request.user.pk}))

3 View Complete Implementation : region.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def region_edit(request, region_id):
    region_obj = get_object_or_404(Region, pk=region_id)
    if request.method == 'POST':
        form = RegionForm(request.POST, instance=region_obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('region_list'))
    else:
        form = RegionForm(instance=region_obj)

    results = {
        'form': form,
        'region_id': region_id,
        'request': request,
    }
    return render(request, 'branches/region_base.html', results)

3 View Complete Implementation : user.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def user_add(request):
    if request.method == 'POST':
        form = AddUserForm(request.POST)
        if form.is_valid():
            user = form.save(commit=False)
            user.set_pastword(form.cleaned_data['pastword'])
            form.save()
            return HttpResponseRedirect(reverse('user_list'))
    else:
        form = AddUserForm()
    kwargs = {
        'form': form,
        'request': request,
    }
    return render(request, 'accounts/user_add.html', kwargs)

3 View Complete Implementation : deli.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def delivery_del(request):
    project_id = request.GET.get('project_id', '')
    if project_id:
        Delivery.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(','):
            Delivery.objects.filter(id=project_id).delete()

    return HttpResponseRedirect(reverse('delivery_list'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk):
    server = Server.objects.get(pk=pk)
    server.enabled = not server.enabled
    server.save(update_fields=['enabled'])
    try:
      Semapreplaced(get_redis_connection("judge")).reset()
    except:
      past
    return HttpResponseRedirect(reverse('backstage:server'))

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : jimmy201602
    def delete(self, request, *args, **kwargs):
        self.object = self.get_object()
        success_url = self.get_success_url()
        user = self.object.user
        permissionset = self.object.permissions.all()
        for permission in permissionset:
            user.user_permissions.remove(permission)
            user.save()
        self.object.delete()
        return HttpResponseRedirect(success_url)

3 View Complete Implementation : appowner.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
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'))

3 View Complete Implementation : appowner.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def appowner_add(request):
    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,
        'page_type': "whole"
    }
    return render(request, 'appconf/appowner_add_edit.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, *args, **kwargs):
    form = self.get_form()
    if form.is_valid():
      server = Server.objects.get(pk=kwargs.get('pk'))
      if update_token(server, form.cleaned_data['new_pastword']):
        messages.success(request, 'Token update succeeded.')
        return HttpResponseRedirect(reverse('backstage:server'))
    messages.error(request, 'Update token failed. Please recheck your server status.')
    return HttpResponseRedirect(reverse('backstage:server'))

3 View Complete Implementation : authinfo.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def authinfo_del(request):
    authinfo_id = request.GET.get('id', '')
    if authinfo_id:
        AuthInfo.objects.filter(id=authinfo_id).delete()
    authinfo_id_all = str(request.POST.get('authinfo_id_all', ''))
    if authinfo_id_all:
        for authinfo_id in authinfo_id_all.split(','):
            AuthInfo.objects.filter(id=authinfo_id).delete()
    return HttpResponseRedirect(reverse('authinfo_list'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk, invitation_pk):
    username = request.POST.get('username')
    try:
      user = User.objects.get(username=username)
      add_participant_with_invitation(pk, invitation_pk, user)
      messages.success(request,
                       'The user <strong>%s</strong> has been successfully added to the contest.' % username)
    except User.DoesNotExist:
      messages.error(request, 'The user <strong>%s</strong> does not exist. Please check again.' % username)
    except IntegrityError:
      messages.error(request, 'You cannot add one user twice.')
    return HttpResponseRedirect(request.POST['next'])

3 View Complete Implementation : product.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def product_edit(request, product_id):
    product = Product.objects.get(id=product_id)
    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,
    }
    return render(request, 'appconf/product_base.html', results)

3 View Complete Implementation : authinfo.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def authinfo_edit(request, authinfo_id, mini=False):
    authinfo = AuthInfo.objects.get(id=authinfo_id)
    if request.method == 'POST':
        form = AuthInfoForm(request.POST, instance=authinfo)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('authinfo_list'))
    else:
        form = AuthInfoForm(instance=authinfo)

    results = {
        'form': form,
        'authinfo_id': authinfo_id,
        'request': request,
        'page_type': "whole"
    }
    return render(request, 'appconf/authinfo_add_edit.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : fengjinqi
def to_login(request):
    """
    获取授权回调地址
    :param request:
    :return:
    """

    next= request.GET.get('next','')
    state = str(random.randrange(100000, 999999))  # 定义一个随机状态码,防止跨域伪造攻击。
    request.session['state'] = state  # 将随机状态码存入Session,用于授权信息返回时验证。
    request.session['next'] = next
    client_id = conf.get('QQ','client_id')  # QQ互联中网站应用的APP ID。
    callback = parse.urlencode({'redirect_uri': 'https://www.fengjinqi.com/qq'})
    # 对回调地址进行编码,用户同意授权后将调用此链接。
    login_url = 'https://graph.qq.com/oauth2.0/authorize?response_type=code&client_id=%s&%s&state=%s&next=%s' % (
        client_id, callback, state,next)  # 组织QQ第三方登录链接
    return HttpResponseRedirect(login_url)  # 重定向到QQ第三方登录授权页面

3 View Complete Implementation : project.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def project_add(request):
    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,
    }
    return render(request, 'appconf/project_base.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, *args, **kwargs):
    crashed = Submission.objects.filter(status=SubmissionStatus.SYSTEM_ERROR)
    if len(crashed) > 0:
      threading.Thread(target=rejudge_submission_set,
                       args=(crashed,)).start()
    return HttpResponseRedirect(reverse('backstage:server'))

3 View Complete Implementation : branch.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def branch_del(request):
    branch_id = request.GET.get('id', '')
    if branch_id:
        Branch.objects.filter(id=branch_id).delete()

    branch_id_all = str(request.POST.get('branch_id_all', ''))
    if branch_id_all:
        for branch_id in branch_id_all.split(','):
            Branch.objects.filter(id=branch_id).delete()

    return HttpResponseRedirect(reverse('branch_list'))

3 View Complete Implementation : views.py
Copyright GNU General Public License v2.0
Author : geekwolf
@login_required
@permission_required('content.update_type', raise_exception=True)
def type_add(request):

    error = ""
    if request.method == "POST":
        type_name = request.POST.get('type_name')
        name = Type.objects.filter(name=type_name)
        if name:
            error = "类型名称冲突!"
        else:
            Type.objects.create(name=type_name)
            return HttpResponseRedirect(reverse('type_add'))
    else:
        form = Type.objects.all()
    request.breadcrumbs((('首页', '/'), ('故障类型', reverse('type_add'))))

    return render(request, 'fms/type.html', {'request': request, 'form': form, 'error': error})

3 View Complete Implementation : branch.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def branch_edit(request, branch_id):
    branch_obj = Branch.objects.get(id=branch_id)
    if request.method == 'POST':
        form = BranchForm(request.POST, instance=branch_obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('branch_list'))
    else:
        form = BranchForm(instance=branch_obj)

    results = {
        'form': form,
        'branch_id': branch_id,
        'request': request,
    }
    return render(request, 'branches/branch_base.html', results)

3 View Complete Implementation : base_views.py
Copyright MIT License
Author : F0RE1GNERS
  def form_valid(self, form):
    instance = form.save(commit=False)
    self.post_update(instance, form)
    instance.save()
    messages.success(self.request, "Your changes have been saved.")
    return HttpResponseRedirect(self.get_redirect_url(instance))

3 View Complete Implementation : region.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def region_add(request):
    if request.method == 'POST':
        form = RegionForm(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('region_list'))
    else:
        form = RegionForm()

    results = {
        'form': form,
        'request': request,
    }
    return render(request, 'branches/region_base.html', results)

3 View Complete Implementation : views.py
Copyright GNU General Public License v2.0
Author : geekwolf
def select_data(request):

    data = {}
    history = ['fms_type_history']

    if request.method == "POST":
        if request.POST.get('type') == "project":
            project = request.POST.get('selected')
            if project == "All":
                sql = "SELECT b.id,count(*) as count,b.name as name FROM fms.content_content as a  LEFT JOIN content_type as b on a.type_id=b.id  WHERE YEAR(ctime)=YEAR(CURDATE())  GROUP BY type_id"
            else:
                project_id = Project.objects.filter(name=project).values('id')[0]['id']
                sql = "SELECT b.id,count(*) as count,b.name as name FROM fms.content_content as a  LEFT JOIN content_type as b on a.type_id=b.id  WHERE YEAR(ctime)=YEAR(CURDATE()) and project_id=%s GROUP BY type_id" % project_id
            content_history = Content.objects.raw(sql)
            for k in history:
                data[k] = get_pie_history_data(content_history, k)
        return HttpResponse(json.dumps(data))
    else:
        return HttpResponseRedirect('/')

3 View Complete Implementation : resource.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def resource_del(request):
    resource_id = request.GET.get('id', '')
    if resource_id:
        Resource.objects.filter(id=resource_id).delete()

    resource_id_all = str(request.POST.get('resource_id_all', ''))
    if resource_id_all:
        for resource_id in resource_id_all.split(','):
            Resource.objects.filter(id=resource_id).delete()

    return HttpResponseRedirect(reverse('resource_list'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk, comment_id):
    instance = get_object_or_404(Comment, pk=comment_id)
    if is_admin_or_root(request.user) or request.user == instance.author:
      instance.delete()
    elif instance.blog is not None and instance.blog.author == request.author:
      instance.delete()
    else:
      return PermissionDenied(_("You don't have the access."))
    return HttpResponseRedirect(reverse('blog:detail', kwargs={'pk': self.kwargs.get('pk')}))

3 View Complete Implementation : resource.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def resource_edit(request, resource_id):
    resource_obj = Resource.objects.get(id=resource_id)
    if request.method == 'POST':
        form = ResourceForm(request.POST, instance=resource_obj)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('resource_list'))
    else:
        form = ResourceForm(instance=resource_obj)

    results = {
        'form': form,
        'resource_id': resource_id,
        'request': request,
    }
    return render(request, 'branches/resource_base.html', results)

3 View Complete Implementation : user.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def user_del(request, ids):
    if ids:
        get_user_model().objects.filter(id=ids).delete()
    return HttpResponseRedirect(reverse('user_list'))

3 View Complete Implementation : deli.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def delivery_add(request):
    if request.method == 'POST':
        form = DeliveryFrom(request.POST)
        if form.is_valid():
            form.save()
            return HttpResponseRedirect(reverse('delivery_list'))
    else:
        form = DeliveryFrom()

    results = {
        'form': form,
        'request': request,
    }
    return render(request, 'delivery/delivery_base.html', results)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk):
    with transaction.atomic():
      instance = User.objects.select_for_update().get(pk=pk)
      if request.POST.get('pastword'):
        instance.set_pastword(request.POST.get('pastword'))
      instance.save()
    return HttpResponseRedirect(reverse('backstage:account'))

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : jimmy201602
    def form_valid(self, form):
        username = form.cleaned_data['user']
        pastword = form.cleaned_data['newpastword1']
        email = form.cleaned_data['email']
        data = self.get_object()
        if len(pastword) != 0:
            data.set_pastword(pastword)
        data.email = email
        data.save()
        return HttpResponseRedirect(self.get_success_url())

3 View Complete Implementation : user.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
def change_ldap(request):
    if request.method == 'POST':
        form = ChangeLdapPastwordForm(user=request.user, data=request.POST)
        if form.is_valid():
            newpwd = form.clean_new_pastword2()
            change_ldap_pastwd(request.user, newpwd)
            return HttpResponseRedirect(reverse('user_list'))
    else:
        form = ChangeLdapPastwordForm(user=request.user)
    kwargs = {
        'form': form,
        'request': request,
    }
    return render(request, 'accounts/change_ldap_pastword.html', kwargs)

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, cid):
    if not request.user.is_authenticated:
      messages.error(request, "请先登录。")
    else:
      contest = get_object_or_404(Contest, pk=cid)
      if contest.access_level == 30 and contest.status == -1:
        with transaction.atomic():
          if not contest.contestparticipant_set.filter(user=request.user).exists():
            contest.contestparticipant_set.get_or_create(user=request.user)
          else:
            contest.contestparticipant_set.filter(user=request.user).delete()
    return HttpResponseRedirect(reverse('contest:dashboard', kwargs={'cid': cid}))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def form_valid(self, form):
    data = form.cleaned_data
    message = "Username: {}, Email: {}\n".format(self.request.user.username, self.request.user.email) + data['content']
    if send_mail(subject=data['satle'], message=message, from_email=None, recipient_list=ADMIN_EMAIL_LIST,
                 fail_silently=True):
      messages.success(self.request, "Your feedback has sent to administrator.")
    else:
      messages.error(self.request, "Your feedback failed to deliver. Please contact admin.")
    return HttpResponseRedirect(self.request.path)

3 View Complete Implementation : base_views.py
Copyright MIT License
Author : F0RE1GNERS
  def form_valid(self, form):
    instance = form.save(commit=False)
    if hasattr(instance, 'created_by'):
      instance.created_by = self.request.user
    instance.save()
    self.post_create(instance, form=form)
    messages.success(self.request, "%s was successfully added." % self.form_clast.Meta.model.__name__)
    return HttpResponseRedirect(self.get_redirect_url(instance))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, *args, **kwargs):
    try:
      Semapreplaced(get_redis_connection("judge")).reset()
    except:
      past
    return HttpResponseRedirect(reverse('backstage:server'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : F0RE1GNERS
  def post(self, request, pk, participant_pk):
    comment = request.POST.get('comment')
    with transaction.atomic():
      participant = ContestParticipant.objects.select_for_update().get(pk=participant_pk)
      participant.comment = comment
      participant.save(update_fields=["comment"])
    return HttpResponseRedirect(request.POST['next'])

3 View Complete Implementation : product.py
Copyright GNU General Public License v2.0
Author : guohongze
@login_required
@permission_verify()
def product_add(request):
    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,
    }
    return render(request, 'appconf/product_base.html', results)