django.http.QueryDict

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

152 Examples 7

Example 1

Project: django-formtools Source File: tests.py
Function: test_initial_call_with_params
    def test_initial_call_with_params(self):
        get_params = {'getvar1': 'getval1', 'getvar2': 'getval2'}
        response = self.client.get(reverse('%s_start' % self.wizard_urlname),
                                   get_params)
        self.assertEqual(response.status_code, 302)

        # Test for proper redirect GET parameters
        location = response.url
        self.assertNotEqual(location.find('?'), -1)
        querydict = QueryDict(location[location.find('?') + 1:])
        self.assertEqual(dict(querydict.items()), get_params)

Example 2

Project: django-simple-sso Source File: server.py
    def success(self):
        self.token.user = self.request.user
        self.token.save()
        serializer = URLSafeTimedSerializer(self.token.consumer.private_key)
        parse_result = urlparse(self.token.redirect_to)
        query_dict = QueryDict(parse_result.query, mutable=True)
        query_dict['access_token'] = serializer.dumps(self.token.access_token)
        url = urlunparse((parse_result.scheme, parse_result.netloc, parse_result.path, '', query_dict.urlencode(), ''))
        return HttpResponseRedirect(url)

Example 3

Project: Django-facebook Source File: api.py
    def my_image_url(self, size='large'):
        '''
        Returns the image url from your profile
        Shortcut for me/picture

        :param size:
            the type of the image to request, see facebook for available formats

        :returns: string
        '''
        query_dict = QueryDict('', True)
        query_dict['type'] = size
        query_dict['access_token'] = self.access_token

        url = '%sme/picture?%s' % (self.api_url, query_dict.urlencode())
        return url

Example 4

Project: django-compositepks Source File: modpython.py
Function: load_post_and_files
    def _load_post_and_files(self):
        "Populates self._post and self._files"
        if self.method != 'POST':
            self._post, self._files = http.QueryDict('', encoding=self._encoding), datastructures.MultiValueDict()
            return

        if 'content-type' in self._req.headers_in and self._req.headers_in['content-type'].startswith('multipart'):
            self._raw_post_data = ''
            try:
                self._post, self._files = self.parse_file_upload(self.META, self._req)
            except:
                # See django.core.handlers.wsgi.WSGIHandler for an explanation
                # of what's going on here.
                self._post = http.QueryDict('')
                self._files = datastructures.MultiValueDict()
                self._post_parse_error = True
                raise
        else:
            self._post, self._files = http.QueryDict(self.raw_post_data, encoding=self._encoding), datastructures.MultiValueDict()

Example 5

Project: django-hyperadmin Source File: states.py
    def get_link_url(self, link):
        url = link.get_base_url()
        params = self.get('extra_get_params', None) or QueryDict('', mutable=True)
        if params:
            params = copy(params)
            if '?' in url:
                url, get_string = url.split('?', 1)
                url_args = QueryDict(get_string)
                if hasattr(params, 'setlist'):
                    for key, value in url_args.iterlists():
                        params.setlist(key, value)
                else:
                    params.update(url_args)
            if hasattr(params, 'urlencode'):
                params = params.urlencode()
            else:
                params = urlencode(params)
            url += '?' + params
        return url

Example 6

Project: amy Source File: test_reports.py
    def test_embedded_iterator_listified(self):
        """Regression: test if advanced structure, generated e.g. by
        `all_activity_over_time` report, doesn't raise RepresenterError when
        used with YAML renderer."""
        t = TestBase()
        t.setUp()
        t._setUpTags()

        format_ = 'yaml'
        self.assertIn(format_, self.formats)

        rvs = ReportsViewSet()
        mock_request = MagicMock()
        mock_request.query_params = QueryDict()
        data = rvs.all_activity_over_time(mock_request, format=format_).data
        self.assertEqual(type(data['missing']['attendance']), type([]))
        self.assertEqual(type(data['missing']['instructors']), type([]))

Example 7

Project: django-tastypie Source File: paginator.py
    def test_page3_with_request(self):
        for req in [{'offset': '4', 'limit': '2'},
                QueryDict('offset=4&limit=2')]:
            paginator = Paginator(req, self.data_set,
                resource_uri='/api/v1/notes/', limit=2, offset=4)
            meta = paginator.page()['meta']
            self.assertEqual(meta['limit'], 2)
            self.assertEqual(meta['offset'], 4)
            self.assertTrue('limit=2' in meta['previous'])
            self.assertTrue('offset=2' in meta['previous'])
            self.assertEqual(meta['next'], None)
            self.assertEqual(meta['total_count'], 6)

Example 8

Project: SmartElect Source File: test_tags.py
    def test_build_page_link(self):
        # build_page_link updates the page parm without breaking other parms
        request = MagicMock(
            GET=QueryDict(u'parm1=1&parm1=b&parm2=2&page=18&parm3=3')
        )
        result = build_page_link(request, 13)
        # Old page parm is gone
        self.assertNotIn('page=18', result)
        # New page parm is present
        self.assertIn('page=13', result)
        # Both values of 'parm1' still present
        self.assertIn('parm1=1', result)
        self.assertIn('parm1=b', result)

Example 9

Project: Arkestra Source File: test_news_and_events.py
    def test_filter_on_search_terms_2_matches(self):
        query = QueryDict('text=newer')
        self.itemlist.request.GET = query
        self.itemlist.filter_on_search_terms()
        self.assertEqual(
            list(self.itemlist.items),
            [self.item1, self.item2]
            )

Example 10

Project: django-paypal Source File: models.py
Function: response_dict
    @cached_property
    def response_dict(self):
        """
        Returns a (MultiValueDict) dictionary containing all the parameters returned in the PayPal response.
        """
        # Undo the urlencode done in init
        return QueryDict(self.response)

Example 11

Project: ClassBasedGenericAPI Source File: mixins.py
Function: process_request
    def process_request(self, request):
        if 'application/json' in request.META['CONTENT_TYPE'].lower():
            request.DATA = QueryDict('', mutable=True)
            request.DATA.update(simplejson.loads(request.raw_post_data))
            return request
        
        return super(JSONMixin, self).process_request(request)

Example 12

Project: django-oauth2-provider Source File: tests.py
    def test_fetching_access_token_with_invalid_grant_type(self):
        self.login()
        self._login_and_authorize()
        response = self.client.get(self.redirect_url())

        query = QueryDict(urlparse.urlparse(response['Location']).query)
        code = query['code']

        response = self.client.post(self.access_token_url(), {
            'grant_type': 'invalid_grant_type',
            'client_id': self.get_client().client_id,
            'client_secret': self.get_client().client_secret,
            'code': code
        })

        self.assertEqual(400, response.status_code)
        self.assertEqual('unsupported_grant_type', json.loads(response.content)['error'],
            response.content)

Example 13

Project: django-formwizard Source File: tests.py
Function: test_initial_call_with_params
    def test_initial_call_with_params(self):
        get_params = {'getvar1': 'getval1', 'getvar2': 'getval2'}
        response = self.client.get(reverse('%s_start' % self.wizard_urlname),
                                   get_params)
        self.assertEqual(response.status_code, 302)

        # Test for proper redirect GET parameters
        location = response['Location']
        self.assertNotEqual(location.find('?'), -1)
        querydict = QueryDict(location[location.find('?') + 1:])
        self.assertEqual(dict(querydict.items()), get_params)

Example 14

Project: django-socialite Source File: utils.py
def get_mutable_query_dict(params=None):
    params = params or {}
    q = QueryDict('')
    q = q.copy()
    q.update(params)
    return q

Example 15

Project: researchcompendia Source File: forms.py
Function: init
    def __init__(self, *args, **kwargs):
        super(ArticleFacetedSearchForm, self).__init__(*args, **kwargs)
        self.query_dict = args[0]
        if self.query_dict is None:
            self.query_dict = QueryDict({})
        self.compendium_types = self.query_dict.getlist('compendium_type', [])
        self.research_fields = self.query_dict.getlist('primary_research_field', [])
        logger.debug('compendium_types %s', self.compendium_types)
        logger.debug('research_fields %s', self.research_fields)

Example 16

Project: django-haystack Source File: test_views.py
    def test_list_selected_facets(self):
        fsv = FacetedSearchView()
        fsv.request = HttpRequest()
        fsv.request.GET = QueryDict('')
        fsv.form = fsv.build_form()
        self.assertEqual(fsv.form.selected_facets, [])

        fsv = FacetedSearchView()
        fsv.request = HttpRequest()
        fsv.request.GET = QueryDict('selected_facets=author:daniel&selected_facets=author:chris')
        fsv.form = fsv.build_form()
        self.assertEqual(fsv.form.selected_facets, [u'author:daniel', u'author:chris'])

Example 17

Project: django-rest-framework Source File: parsers.py
    def parse(self, stream, media_type=None, parser_context=None):
        """
        Parses the incoming bytestream as a URL encoded form,
        and returns the resulting QueryDict.
        """
        parser_context = parser_context or {}
        encoding = parser_context.get('encoding', settings.DEFAULT_CHARSET)
        data = QueryDict(stream.read(), encoding=encoding)
        return data

Example 18

Project: django-nested-forms Source File: tests.py
    def test_bad_form(self):
        query_string = "toto=titi"
        q = QueryDict(query_string)

        form = self.ThirdPartyForm(q, instance=self.third_party)

        self.assertFalse(form.is_valid())

Example 19

Project: qualitio Source File: building_forms_from_params_test.py
    def test_should_have_proper_number_of_forms(self):
        params = QueryDict('&'.join([
                    '1-0-1-to_date=',
                    '1-0-1-from_date=',
                    '1-1-1-to_date=',
                    '1-1-1-from_date=',
                    '1-4-1-q=',

                    '2-4-1-q=3',

                    '3-4-1-q=',
                    ]))
        self.assertFilterGroupConsistency(params, expected_number_of_groups=3, expected_number_of_forms=5)

Example 20

Project: Arkestra Source File: test_news_and_events.py
    def test_filter_on_search_terms_no_terms(self):
        query = QueryDict("")
        self.itemlist.request.GET = query
        self.itemlist.filter_on_search_terms()
        self.assertEqual(
            list(self.itemlist.items),
            [self.item1, self.item2]
            )

Example 21

Project: django-autocomplete-light Source File: test_forms.py
Function: test_validate
    def test_validate(self):
        pass
        # Create an option to select
        fixture = TestModel.objects.create(name=self.id(), owner=self.owner)

        # Instantiate the form with the fixture selected but with wrong owner
        form = TestForm(http.QueryDict('name=%s&owner=%s&test=%s' % (
            self.id(), self.other_user.id, fixture.id)))

        # Form should not validate
        self.assertFalse(form.is_valid())

Example 22

Project: django-hyperadmin Source File: links.py
Function: get_base_url
    def get_base_url(self):
        #include_form_params_in_url=False
        if self.get_link_factor() == 'LT' and self.include_form_params_in_url: #TODO absorb this in link._url
            if '?' in self._url:
                base_url, url_params = self._url.split('?', 1)
            else:
                base_url, url_params = self._url, ''
            params = QueryDict(url_params, mutable=True)
            form = self.get_form()
            #extract get params
            for field in form:
                val = field.value()
                if val is not None:
                    params[field.html_name] = val
            return '%s?%s' % (base_url, params.urlencode())
        return self._url

Example 23

Project: qualitio Source File: building_forms_from_params_test.py
    def test_problematic(self):
        params = QueryDict('&'.join([
                    '1-0-1-from_date=',
                    '1-0-1-to_date=',
                    '1-1-1-from_date=',
                    '1-1-1-to_date=',
                    '1-4-1-q=1',

                    '2-4-1-q=3',

                    '3-4-1-q=',

                    '4-4-1-q=',

                    '5-1-1-from_date=',
                    '5-1-1-to_date=',
                    ]))
        self.assertFilterGroupConsistency(params, expected_number_of_groups=5, expected_number_of_forms=7)

Example 24

Project: zulip Source File: decorator.py
def redirect_to_login(next, login_url=None,
                      redirect_field_name=REDIRECT_FIELD_NAME):
    # type: (text_type, Optional[text_type], text_type) -> HttpResponseRedirect
    """
    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(urllib.parse.urlparse(resolved_url))
    if redirect_field_name:
        querystring = QueryDict(login_url_parts[4], mutable=True)
        querystring[redirect_field_name] = next
        # Don't add ?next=/, to keep our URLs clean
        if next != '/':
            login_url_parts[4] = querystring.urlencode(safe='/')

    return HttpResponseRedirect(urllib.parse.urlunparse(login_url_parts))

Example 25

Project: django-paypal Source File: models.py
    @cached_property
    def posted_data_dict(self):
        """
        All the data that PayPal posted to us, as a correctly parsed dictionary of values.
        """
        if not self.query:
            return None
        from django.http import QueryDict
        roughdecode = dict(item.split('=', 1) for item in self.query.split('&'))
        encoding = roughdecode.get('charset', None)
        if encoding is None:
            encoding = DEFAULT_ENCODING
        query = self.query.encode('ascii')
        data = QueryDict(query, encoding=encoding)
        return data.dict()

Example 26

Project: djtables Source File: test_table.py
def test_builds_urls():
    req = HttpRequest()
    req.GET = QueryDict("a=1", encoding="utf-8")
    req.path = "/"

    t = TestTable(request=req)

    assert t.get_url() == "/?a=1"
    assert t.get_url(a=2) == "/?a=2"

    # either is valid, since param order is undefined.
    assert t.get_url(b=3) in ["/?a=1&b=3", "/?b=3&a=1"]

Example 27

Project: canvas Source File: tests_helpers.py
    def __init__(self, user=None, path=None, GET={}, extra_META={}):
        HttpRequest.__init__(self)
        self.user = user or AnonymousUser()
        self.user_kv = {}
        if hasattr(self.user, 'redis'):
            self.user_kv = self.user.redis.user_kv.hgetall()
        self.session = SessionStore(session_key='skey')
        self.experiments = create_experiments_for_request(self)
        self.META = {"REMOTE_ADDR": "127.0.0.1", "PATH_INFO": path}
        self.META.update(extra_META)
        if path is not None:
            self.path = path

        if GET is not None:
            self.GET = QueryDict(GET)

Example 28

Project: froide Source File: views.py
Function: get_context_data
    def get_context_data(self, **kwargs):
        context = super(BaseRequestListView, self).get_context_data(**kwargs)
        no_page_query = QueryDict(self.request.GET.urlencode().encode('utf-8'),
                                  mutable=True)
        no_page_query.pop('page', None)
        context['getvars'] = no_page_query.urlencode()
        context['menu'] = self.menu_item
        return context

Example 29

Project: datal Source File: views.py
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
    """
    if not login_url:
        login_url = settings.LOGIN_URL

    login_url_parts = list(urlparse.urlparse(login_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(urlparse.urlunparse(login_url_parts))

Example 30

Project: rapidsms Source File: tests.py
    def test_registration_render(self):
        # render actually works (django_tables2 and all)
        request = HttpRequest()
        request.GET = QueryDict('')
        self.login()
        request.user = self.user
        retval = views.registration(request)
        self.assertEqual(200, retval.status_code)

Example 31

Project: django-modernizr Source File: middleware.py
    def load_modernizr_from_storage(self, request):
        data = None
        if settings.MODERNIZR_STORAGE == 'cookie':
            if settings.MODERNIZR_COOKIE_NAME in request.COOKIES:
                data = QueryDict(request.COOKIES[settings.MODERNIZR_COOKIE_NAME])
        elif settings.MODERNIZR_STORAGE == 'session':
            data = request.session.get(settings.MODERNIZR_SESSION_KEY)

        if data is not None:
            request.modernizr = dict([(k, bool(int(v))) for k,v in data.items()])
        else:
            request.modernizr = None

Example 32

Project: amy Source File: test_reports.py
    def test_listify_query_param(self):
        """Regression test: make sure it's possible to iterate through results
        serialized with CSV or YAML serializer.

        This test uses `?format' query param."""
        rvs = ReportsViewSet()
        for format_ in self.formats:
            with self.subTest(format=format_):
                mock_request = MagicMock()
                mock_request.query_params = QueryDict('format={}'
                                                      .format(format_))
                result = rvs.listify(self.iterable, mock_request)
                self.assertEqual(type(result), type(list()))

Example 33

Project: ting Source File: views.py
Function: patch
    @privileged
    def patch(self, request, id, *args, **kwargs):
        qdict = QueryDict(request.body)

        message = Message.objects.get(pk=id)

        form = MessagePatchForm(qdict)

        if not form.is_valid() or not message.typing:
            return HttpResponseBadRequest(str(form.errors))

        form.save(message)

        return HttpResponse(status=204)

Example 34

Project: pythondigest Source File: models.py
Function: build_url
def build_url(*args, **kwargs):
    params = kwargs.pop('params', {})
    url = reverse(*args, **kwargs)
    if not params:
        return url

    query_dict = QueryDict('', mutable=True)
    for k, v in params.items():
        if type(v) is list:
            query_dict.setlist(k, v)
        else:
            query_dict[k] = v

    return url + '?' + query_dict.urlencode()

Example 35

Project: django-haystack Source File: test_views.py
Function: test_empty_results
    def test_empty_results(self):
        fsv = FacetedSearchView()
        fsv.request = HttpRequest()
        fsv.request.GET = QueryDict('')
        fsv.form = fsv.build_form()
        self.assertTrue(isinstance(fsv.get_results(), EmptySearchQuerySet))

Example 36

Project: taiga-back Source File: parsers.py
    def parse(self, stream, media_type=None, parser_context=None):
        """
        Parses the incoming bytestream as a URL encoded form,
        and returns the resulting QueryDict.
        """
        parser_context = parser_context or {}
        encoding = parser_context.get("encoding", settings.DEFAULT_CHARSET)
        data = QueryDict(stream.read(), encoding=encoding)
        return data

Example 37

Project: django-tastypie Source File: paginator.py
    def test_page2_with_request(self):
        for req in [{'offset': '2', 'limit': '2'},
                QueryDict('offset=2&limit=2')]:
            paginator = Paginator(req, self.data_set,
                resource_uri='/api/v1/notes/', limit=2, offset=2)
            meta = paginator.page()['meta']
            self.assertEqual(meta['limit'], 2)
            self.assertEqual(meta['offset'], 2)
            self.assertTrue('limit=2' in meta['previous'])
            self.assertTrue('offset=0' in meta['previous'])
            self.assertTrue('limit=2' in meta['next'])
            self.assertTrue('offset=4' in meta['next'])
            self.assertEqual(meta['total_count'], 6)

Example 38

Project: django-concurrency Source File: test_issues.py
def get_fake_request(params):
    u, __ = User.objects.get_or_create(username='sax')
    setattr(u, 'is_authenticated()', True)
    setattr(u, 'selected_office', False)

    request = RequestFactory().request()
    request.user = u

    querydict = QueryDict(params)
    request.POST = querydict

    return request

Example 39

Project: django-nested-forms Source File: tests.py
    def test_click_on_add_button_should_have_1_subform(self):
        """
        Le click sur un bouton génère 2 variables passées au formulaire
        """
        query_string = "&".join([
            "contacts-%(total)s=0",
            "contacts-%(total)s=1",
            "contacts-%(initial)s=0",
        ]) % {
            'total': TOTAL_FORM_COUNT,
            'initial': INITIAL_FORM_COUNT,
        }

        q = QueryDict(query_string)
        form = self.ThirdPartyForm(q)
        self.assertEqual(len(form.formsets['contacts'].forms), 1)

Example 40

Project: django-organizations Source File: test_backends.py
    def test_register_existing(self):
        """Ensure that an existing user is redirected to login"""
        backend = RegistrationBackend()
        request = request_factory_login(self.factory)
        request.POST = QueryDict("name=Mudhoney&slug=mudhoney&[email protected]")
        self.assertEqual(302, backend.create_view(request).status_code)

Example 41

Project: edx-platform Source File: test_views.py
Function: test_instructor_task_status_list
    def test_instructor_task_status_list(self):
        # Fetch status for existing tasks by arg list, as if called from ajax.
        # Note that ajax does something funny with the marshalling of
        # list data, so the key value has "[]" appended to it.
        task_ids = [(self._create_failure_entry()).task_id for _ in range(1, 5)]
        request = Mock()
        task_ids_query_dict = QueryDict(mutable=True)
        task_ids_query_dict.update({'task_ids[]': task_ids})
        request.GET = request.POST = task_ids_query_dict
        response = instructor_task_status(request)
        output = json.loads(response.content)
        self.assertEquals(len(output), len(task_ids))
        for task_id in task_ids:
            self.assertEquals(output[task_id]['task_id'], task_id)

Example 42

Project: pulp Source File: test_search.py
    @mock.patch('pulp.server.webservices.views.decorators._verify_auth',
                new=assert_auth_READ())
    @mock.patch('pulp.server.webservices.views.search.SearchView._parse_args')
    def test_get_with_invalid_filters(self, mock_parse):
        """
        InvalidValue should be raised if param 'filters' is not json.
        """
        mock_parse.return_value = ({'mock': 'query'}, 'tuple')
        search_view = search.SearchView()
        mock_request = mock.MagicMock()
        mock_request.GET = http.QueryDict('filters=invalid json')
        self.assertRaises(exceptions.InvalidValue, search_view.get, mock_request)

Example 43

Project: django-report-tools Source File: api.py
Function: get_chart
def get_chart(request, api_key, chart_name, parameters=None, prefix=None):
    request = copy(request)
    if parameters is not None:
        new_get = QueryDict('', mutable=True)
        new_get.update(parameters)
        request.GET = new_get
    
    report_view_class = report_api_registry.get_report_view_class(api_key)

    if not report_view_class:
        raise ReportNotFoundError("Report not found for api key '%s'. Available reports are '%s'." %
            (api_key, ', '.join(report_api_registry.api_keys)))
    
    report_view = report_view_class()
    
    return report_view.get_chart(request, chart_name, prefix)

Example 44

Project: django-autocomplete-light Source File: test_forms.py
Function: test_save
    def test_save(self):
        # Create an option to select
        fixture = TestModel.objects.create(name='relation' + self.id(),
                                           owner=self.owner)

        # Instantiate the form with the fixture selected
        form = TestForm(http.QueryDict('name=%s&owner=%s&test=%s' % (
            self.id(), self.owner.id, fixture.id)))

        # Ensure that the form is valid
        self.assertTrue(form.is_valid())

        # Ensure that form.save updates the relation field
        instance = form.save()
        self.assertEqual(fixture, instance.test)

        # Ensure that the relation field was properly saved
        self.assertEqual(TestModel.objects.get(pk=instance.pk).test, fixture)

Example 45

Project: SmartElect Source File: test_tags.py
    def test_build_page_link_no_page_before(self):
        # Similar test, but no page parm in the original parms
        request = MagicMock(
            GET=QueryDict(u'parm1=1&parm1=b&parm2=2&parm3=3')
        )
        result = build_page_link(request, 13)
        # New page parm is present
        self.assertIn('page=13', result)
        # Both values of 'parm1' still present
        self.assertIn('parm1=1', result)
        self.assertIn('parm1=b', result)

Example 46

Project: pulp Source File: test_search.py
    @mock.patch('pulp.server.webservices.views.decorators._verify_auth',
                new=assert_auth_READ())
    @mock.patch('pulp.server.webservices.views.search.SearchView._generate_response')
    def test_get_with_options(self, mock_gen_response):
        """
        Test the GET search handler without any search parameters passed, but with options.
        """
        class FakeSearchView(search.SearchView):
            model = mock.MagicMock()
            _parse_args = mock.MagicMock(return_value=('query', 'options'))

        request = mock.MagicMock()
        request.GET = http.QueryDict('details=true')
        view = FakeSearchView()
        results = view.get(request)

        FakeSearchView._parse_args.assert_called_once_with({'details': 'true'})
        mock_gen_response.assert_called_once_with('query', 'options')
        self.assertTrue(results is mock_gen_response.return_value)

Example 47

Project: PyClassLessons Source File: views.py
Function: redirect_to_login
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))

Example 48

Project: rapidsms Source File: tests.py
    def test_registration(self):
        # The registration view calls render with a context that has a
        # contacts_table that has the contacts in its data
        request = HttpRequest()
        request.GET = QueryDict('')
        self.login()
        request.user = self.user
        with patch('rapidsms.contrib.registration.views.render') as render:
            views.registration(request)
        context = render.call_args[0][2]
        table = context["contacts_table"]
        self.assertEqual(len(self.contacts), len(list(table.data.queryset)))

Example 49

Project: xadmin Source File: bookmark.py
Function: set_up
    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 = unicode(bookmark)

        req = self.make_get_request("", data.items())
        self.list_view = self.get_view_class(
            ListAdminView, model, list_per_page=10, list_editable=[])(req)

Example 50

Project: djtables Source File: test_table.py
def test_request_override_options():
    req = HttpRequest()
    req.GET = QueryDict(
        "order_by=name&per_page=3",
        encoding="utf-8")

    t = TestTable(request=req)
    assert t._meta.order_by == "name"
    assert t._meta.per_page == 3
See More Examples - Go to Next Page
Page 1 Selected Page 2 Page 3 Page 4