当前位置: 首页>>代码示例>>Python>>正文


Python http.QueryDict方法代码示例

本文整理汇总了Python中django.http.QueryDict方法的典型用法代码示例。如果您正苦于以下问题:Python http.QueryDict方法的具体用法?Python http.QueryDict怎么用?Python http.QueryDict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.http的用法示例。


在下文中一共展示了http.QueryDict方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: list_orders

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def list_orders(request):
    """
    orders/index
    """
    args = request.GET.copy()
    default = {'state': Order.STATE_QUEUED}

    if len(args) < 2:  # search form not submitted
        f = request.session.get("order_search_filter", default)
        args = QueryDict('', mutable=True)
        args.update(f)

    request.session['order_search_filter'] = args
    data = prepare_list_view(request, args)

    return render(request, "orders/index.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:18,代码来源:order.py

示例2: redirect_to_login

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def redirect_to_login(next, login_url=None,
                      redirect_field_name=REDIRECT_FIELD_NAME):
    """
    Redirects the user to the login page, passing the given 'next' page
    """
    resolved_url = resolve_url(login_url or settings.LOGIN_URL)

    login_url_parts = list(urlparse(resolved_url))
    if redirect_field_name:
        querystring = QueryDict(login_url_parts[4], mutable=True)
        querystring[redirect_field_name] = next
        login_url_parts[4] = querystring.urlencode(safe='/')

    return HttpResponseRedirect(urlunparse(login_url_parts))


# 4 views for password reset:
# - password_reset sends the mail
# - password_reset_done shows a success message for the above
# - password_reset_confirm checks the link the user clicked and
#   prompts for a new password
# - password_reset_complete shows a success message for the above 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:24,代码来源:views.py

示例3: test_ocpcpuview_success

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_ocpcpuview_success(self, mock_handler):
        """Test OCP cpu view report."""
        mock_handler.return_value.execute_query.return_value = self.report_ocp_cpu
        params = {
            "group_by[node]": "*",
            "filter[resolution]": "monthly",
            "filter[time_scope_value]": "-1",
            "filter[time_scope_units]": "month",
        }
        user = User.objects.get(username=self.user_data["username"])

        django_request = HttpRequest()
        if not django_request.META.get("HTTP_HOST"):
            django_request.META["HTTP_HOST"] = "testhost"

        qd = QueryDict(mutable=True)
        qd.update(params)
        django_request.GET = qd
        request = Request(django_request)
        request.user = user

        response = OCPCpuView().get(request)
        self.assertIsInstance(response, Response)
        self.assertEqual(response.status_code, status.HTTP_200_OK) 
开发者ID:project-koku,项目名称:koku,代码行数:26,代码来源:tests_views.py

示例4: test_ocpmemview_success

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_ocpmemview_success(self, mock_handler):
        """Test OCP memory view report."""
        mock_handler.return_value.execute_query.return_value = self.report_ocp_mem
        params = {
            "group_by[node]": "*",
            "filter[resolution]": "monthly",
            "filter[time_scope_value]": "-1",
            "filter[time_scope_units]": "month",
        }
        user = User.objects.get(username=self.user_data["username"])

        django_request = HttpRequest()
        if not django_request.META.get("HTTP_HOST"):
            django_request.META["HTTP_HOST"] = "testhost"

        qd = QueryDict(mutable=True)
        qd.update(params)
        django_request.GET = qd
        request = Request(django_request)
        request.user = user

        response = OCPMemoryView().get(request)
        self.assertIsInstance(response, Response)
        self.assertEqual(response.status_code, status.HTTP_200_OK) 
开发者ID:project-koku,项目名称:koku,代码行数:26,代码来源:tests_views.py

示例5: test_costview_with_units_success

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_costview_with_units_success(self, mock_handler):
        """Test unit conversion succeeds in AzureCostView."""
        mock_handler.return_value.execute_query.return_value = self.report
        params = {
            "group_by[subscription_guid]": "*",
            "filter[resolution]": "monthly",
            "filter[time_scope_value]": "-1",
            "filter[time_scope_units]": "month",
            "units": "byte",
            "SERVER_NAME": "",
        }
        user = User.objects.get(username=self.user_data["username"])

        django_request = HttpRequest()
        qd = QueryDict(mutable=True)
        qd.update(params)
        django_request.GET = qd
        request = Request(django_request)
        request.user = user

        response = AzureCostView().get(request)
        self.assertIsInstance(response, Response) 
开发者ID:project-koku,项目名称:koku,代码行数:24,代码来源:tests_views.py

示例6: export_menu

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def export_menu(request, username, id_string):

    req = request.REQUEST
    export_type = req.get('type', None)
    if export_type:
        lang = req.get('lang', None)
        hierarchy_in_labels = req.get('hierarchy_in_labels')
        group_sep = req.get('group_sep', '/')

        q = QueryDict('', mutable=True)
        q['lang'] = req.get('lang')
        q['hierarchy_in_labels'] = req.get('hierarchy_in_labels')
        q['group_sep'] = req.get('group_sep', '/')

        if export_type == "xlsx":
            url = reverse('formpack_xlsx_export', args=(username, id_string))
            return redirect(url + '?' + q.urlencode())
        if export_type == "csv":
            url = reverse('formpack_csv_export', args=(username, id_string))
            return redirect(url + '?' + q.urlencode())

    context = build_export_context(request, username, id_string)
    return render(request, 'survey_report/export_menu.html', context) 
开发者ID:awemulya,项目名称:kobo-predict,代码行数:25,代码来源:views.py

示例7: redirect_to_login

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def redirect_to_login(next, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
    """
    Redirect the user to the login page, passing the given 'next' page.
    """
    resolved_url = resolve_url(login_url or settings.LOGIN_URL)

    login_url_parts = list(urlparse(resolved_url))
    if redirect_field_name:
        querystring = QueryDict(login_url_parts[4], mutable=True)
        querystring[redirect_field_name] = next
        login_url_parts[4] = querystring.urlencode(safe='/')

    return HttpResponseRedirect(urlunparse(login_url_parts))


# 4 views for password reset:
# - password_reset sends the mail
# - password_reset_done shows a success message for the above
# - password_reset_confirm checks the link the user clicked and
#   prompts for a new password
# - password_reset_complete shows a success message for the above 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:23,代码来源:views.py

示例8: test_get_querystring_for_page

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_get_querystring_for_page(self):
        request = self
        request = HttpRequest()
        dict = {u"querystring_key": 1,
                u"key": 2,
                u"page": 3}
        qdict = QueryDict('', mutable=True)
        qdict.update(dict)
        request.GET = qdict
        val = get_querystring_for_page(request=request,
                                       page_number=1,
                                       querystring_key="key",
                                       default_number=1)
        self.assertTrue(bool(val))
        request.GET = {}
        val = get_querystring_for_page(request=request,
                                       page_number=1,
                                       querystring_key="key",
                                       default_number=1)
        self.assertFalse(bool(val)) 
开发者ID:MicroPyramid,项目名称:django-simple-pagination,代码行数:22,代码来源:tests.py

示例9: redirect_to_sudo

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def redirect_to_sudo(next_url, sudo_url=None):
    """
    Redirects the user to the login page, passing the given 'next' page
    """
    if sudo_url is None:
        sudo_url = URL

    try:
        # django 1.10 and greater can't resolve the string 'sudo.views.sudo' to a URL
        # https://docs.djangoproject.com/en/1.10/releases/1.10/#removed-features-1-10
        sudo_url = import_string(sudo_url)
    except (ImportError, ImproperlyConfigured):
        pass  # wasn't a dotted path

    sudo_url_parts = list(urlparse(resolve_url(sudo_url)))

    querystring = QueryDict(sudo_url_parts[4], mutable=True)
    querystring[REDIRECT_FIELD_NAME] = next_url
    sudo_url_parts[4] = querystring.urlencode(safe="/")

    return HttpResponseRedirect(urlunparse(sudo_url_parts)) 
开发者ID:mattrobenolt,项目名称:django-sudo,代码行数:23,代码来源:views.py

示例10: test_parse_bool_false

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_parse_bool_false(self):
        """Tests parsing a required bool parameter that is provided via GET."""
        request = MagicMock(Request)
        request.query_params = QueryDict('', mutable=True)
        request.query_params.update({
            'test1': 'FALSE',
            'test2': 'False',
            'test3': 'false',
            'test4': 'f',
            'test5': '0',
        })

        self.assertFalse(rest_util.parse_bool(request, 'test1'))
        self.assertFalse(rest_util.parse_bool(request, 'test2'))
        self.assertFalse(rest_util.parse_bool(request, 'test3'))
        self.assertFalse(rest_util.parse_bool(request, 'test4'))
        self.assertFalse(rest_util.parse_bool(request, 'test5')) 
开发者ID:ngageoint,项目名称:scale,代码行数:19,代码来源:test_rest.py

示例11: orders

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def orders(request):
    """
    This is basically like orders/index, but limited to the user
    First, filter by the provided search criteria,
    then check if we have a saved search filter
    then default to user id
    Always update saved search filter
    """
    args = request.GET.copy()
    default = {'state': Order.STATE_OPEN}

    if len(args) < 2:
        f = request.session.get("account_search_filter", default)
        args = QueryDict('', mutable=True)
        args.update(f)

    # On the profile page, filter by the user, no matter what
    args.update({'followed_by': request.user.pk})
    request.session['account_search_filter'] = args

    data = prepare_list_view(request, args)
    data['title'] = _("My Orders")

    del(data['form'].fields['assigned_to'])

    return render(request, "accounts/orders.html", data) 
开发者ID:fpsw,项目名称:Servo,代码行数:28,代码来源:account.py

示例12: render_tag

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def render_tag(self, context, kwa):
        q = QueryDict('').copy()
        q.update(kwa)
        return q.urlencode() 
开发者ID:dulacp,项目名称:django-accounting,代码行数:6,代码来源:url_tags.py

示例13: test_advanced_search_3

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def test_advanced_search_3(self):
        client = Client()
        client.login_user('dzhao')
        this_sem = Semester.current()
        units = [r.unit for r in Role.objects_fresh.filter(person__userid='dzhao', role='GRAD')]

        gs = self.__make_test_grad()
        gs.gradstatus_set.all().delete()

        s1 = GradStatus(student=gs, status='COMP', start=this_sem.offset(-4))
        s1.save()
        s2 = GradStatus(student=gs, status='ACTI', start=this_sem.offset(-3))
        s2.save()
        s3 = GradStatus(student=gs, status='LEAV', start=this_sem.offset(2))
        s3.save()
        gs.update_status_fields()

        # test current-status searching
        form = SearchForm(QueryDict('student_status=ACTI&columns=person.emplid'))
        active_now = form.search_results(units)
        self.assertIn(gs, active_now)
        form = SearchForm(QueryDict('student_status=LEAV&columns=person.emplid'))
        leave_now = form.search_results(units)
        self.assertNotIn(gs, leave_now)

        # test status-as-of searching  -- DISABLED since we removed this from the form.
        #form = SearchForm(QueryDict('student_status=ACTI&status_asof=%s&columns=person.emplid' % (this_sem.offset(-4).name)))
        #active_past = form.search_results(units)
        #self.assertNotIn(gs, active_past)
        #form = SearchForm(QueryDict('student_status=COMP&status_asof=%s&columns=person.emplid' % (this_sem.offset(-4).name)))
        #applic_past = form.search_results(units)
        #self.assertIn(gs, applic_past)

        #form = SearchForm(QueryDict('student_status=ACTI&status_asof=%s&columns=person.emplid' % (this_sem.offset(3).name)))
        #active_later = form.search_results(units)
        #self.assertNotIn(gs, active_later)
        #form = SearchForm(QueryDict('student_status=LEAV&status_asof=%s&columns=person.emplid' % (this_sem.offset(3).name)))
        #leave_later = form.search_results(units)
        #self.assertIn(gs, leave_later) 
开发者ID:sfu-fas,项目名称:coursys,代码行数:41,代码来源:tests.py

示例14: provider_end_session_url

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def provider_end_session_url(self):
        """ Returns the end-session URL. """
        q = QueryDict(mutable=True)
        q[oidc_rp_settings.PROVIDER_END_SESSION_REDIRECT_URI_PARAMETER] = \
            self.request.build_absolute_uri(settings.LOGOUT_REDIRECT_URL or '/')
        q[oidc_rp_settings.PROVIDER_END_SESSION_ID_TOKEN_PARAMETER] = \
            self.request.session['oidc_auth_id_token']
        return '{}?{}'.format(oidc_rp_settings.PROVIDER_END_SESSION_ENDPOINT, q.urlencode()) 
开发者ID:impak-finance,项目名称:django-oidc-rp,代码行数:10,代码来源:views.py

示例15: setup

# 需要导入模块: from django import http [as 别名]
# 或者: from django.http import QueryDict [as 别名]
def setup(self):
        BaseWidget.setup(self)

        bookmark = self.cleaned_data['bookmark']
        model = bookmark.content_type.model_class()
        data = QueryDict(bookmark.query)
        self.bookmark = bookmark

        if not self.title:
            self.title = smart_text(bookmark)

        req = self.make_get_request("", data.items())
        self.list_view = self.get_view_class(
            ListAdminView, model, list_per_page=10, list_editable=[])(req) 
开发者ID:stormsha,项目名称:StormOnline,代码行数:16,代码来源:bookmark.py


注:本文中的django.http.QueryDict方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。