當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。