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


Python QueryDict.update方法代码示例

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


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

示例1: get_form_kwargs

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
 def get_form_kwargs(self):
     kwargs = super(RegistrationView, self).get_form_kwargs()
     self.ax = self.request.session['ax']
     if not self.ax:
         self.ax = RegistrationView.get_ax(self.request.POST)
     if self.ax:
         ax_data = {
                 'first_name' : self.ax['firstname'].split(maxsplit=1)[0] if 'firstname' in self.ax.keys() else None,
                 'last_name' : self.ax['lastname'] if 'lastname' in self.ax.keys() else None,
                 'gender' : self.ax['gender'] if 'gender' in self.ax.keys() else None,
                 'street' : self.ax['address'] if 'address' in self.ax.keys() else None,
                 'town' : self.ax['city'] if 'city' in self.ax.keys() else None,
                 'zip' : self.ax['postal_code'] if 'postal_code' in self.ax.keys() else None,
                 'birthday_day' : self.ax['birth_day'] if 'birth_day' in self.ax.keys() else None,
                 'birthday_month' : self.ax['birth_month'] if 'birth_month' in self.ax.keys() else None,
                 'birthday_year' : self.ax['birth_year'] if 'birth_year' in self.ax.keys() else None
         }
         data = QueryDict('', mutable=True)
         data.update(ax_data)
         if 'data' in kwargs.keys():
             data.update(kwargs['data'])
         kwargs['data'] = data
         kwargs.update({'eid' : True})
         self.eid = True
     else:
         kwargs.update({'eid' : False})
     self.request.session['ax'] = self.ax
     return kwargs
开发者ID:dsarkozi,项目名称:care4care-sdp-grp4,代码行数:30,代码来源:RegistrationView.py

示例2: auto_publish

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
def auto_publish(request, category_id=3):
    with open("/home/david/htdocs/feedback_django/example/spirit/topic/json/O.json","r",encoding='UTF-8') as file:
        jsonContent = json.load(file)
        # print(jsonContent['course'][0])
        
        # <QueryDict: {'comment': ['fuck'], 'category': ['5'], 'csrfmiddlewaretoken': ['TrhHjnBCe5pAHjeSKGN4n3kbY3m7SvXh'], 'title': ['auto']}>
        jsondict = {'category': ['3'], 'comment': ['this is test'],
            'csrfmiddlewaretoken': ['TrhHjnBCe5pAHjeSKGN4n3kbY3m7SvXh'], 'title':  ['json works']}
        qdict = QueryDict('',mutable=True)
        qdict.update(jsondict)

    if category_id:
        get_object_or_404(Category.objects.visible(),
                          pk=category_id)

    form = TopicForm(user=request.user, data=qdict)
    cform = CommentForm(user=request.user, data=qdict)
    print(form)
    print(form.is_valid())
    print(cform.is_valid())
    if all([form.is_valid(), cform.is_valid()]):  # TODO: test!
        # wrap in transaction.atomic?
        topic = form.save()
        cform.topic = topic
        comment = cform.save()
        comment_posted(comment=comment, mentions=cform.mentions)
        return redirect(topic.get_absolute_url())

    context = {
        'form': form,
        'cform': cform
    }
    return render(request, 'spirit/topic/publish.html', context)
开发者ID:david30907d,项目名称:feedback_django,代码行数:35,代码来源:views.py

示例3: encode_query

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
def encode_query(querydict):
    """
    Encode a querydict as form params, using '+'' for ' '.
    """
    if not isinstance(querydict, QueryDict):
        temp = querydict
        querydict = QueryDict('', mutable=True)
        querydict.update(temp)
    return querydict.urlencode(': ').replace(' ', '+')
开发者ID:harvard-lil,项目名称:nuremberg,代码行数:11,代码来源:search_url.py

示例4: query_string_from_dict

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
def query_string_from_dict(qs_dict):
    qs_prepared_dict = OrderedDict()
    for key, val in qs_dict.items():
        if isinstance(val, list):
            val = '[%s]' % ','.join([force_text(v) for v in val])
        qs_prepared_dict[key] = val

    qdict = QueryDict('').copy()
    qdict.update(qs_prepared_dict)
    return qdict.urlencode()
开发者ID:matllubos,项目名称:django-chamber,代码行数:12,代码来源:http.py

示例5: send

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def send(self, url, message_data, **kwargs):
        qs = QueryDict(mutable=True)
        qs.update(message_data)

        r = urllib.request.urlopen(urllib.request.Request(
            url,
            qs.urlencode().encode('utf-8'),
        ))

        result = r.read().decode('utf-8')

        return self.validate(r.headers['content-type'], result, message_data)
开发者ID:lamby,项目名称:django-slack,代码行数:14,代码来源:backends.py

示例6: __init__

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def __init__(self, *args, **kwargs):
        super(AutoManagementFormMixin, self).__init__(*args, **kwargs)

        if self.is_bound:
            if isinstance(self.data, MergeDict):
                data = QueryDict(None, mutable=True)
                for d in self.data.dicts:
                    data._encoding = d._encoding
                    data.update(d)
                self.data = data  # Make data mutable
            elif not getattr(self.data, '_mutable', True):
                self.data = self.data.copy()  # Make data mutable
开发者ID:AndrewBloody,项目名称:DUBALU_SMS,代码行数:14,代码来源:forms.py

示例7: query_params

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
 def query_params(self):
     orignal_params = super(BlendedRequest, self).query_params
     if self._params_prefix:
         params = QueryDict(mutable=True)
         params.update({k[len(self._params_prefix):]: v for k, v in orignal_params.items() if k.startswith(self._params_prefix)})
     else:
         params = super(BlendedRequest, self).query_params
     for m_k, m_v in  self._mapped_params.items():
         for o_k, o_v in orignal_params.items():
             matches = re.match(m_v, o_k)
             if matches:
                 params[''.join([m_k, (matches.group(1) if matches.lastindex >= 1 else '')])] = o_v
     return params
开发者ID:predicthq,项目名称:rfhq,代码行数:15,代码来源:mixins.py

示例8: test_chain_setup_saves_chains_correctly

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def test_chain_setup_saves_chains_correctly(self):
        request = HttpRequest()
        request.method = 'POST'
        request.session = self.engine.SessionStore(None)
        request.session['pdb_id'] = '1SC1'
        request.session['all_chains'] = ['A', 'B']
        _dict = {'chains' : 'A'}
        _qdict = QueryDict('', mutable=True)
        _qdict.update(_dict)
        request.POST = _qdict

        response = chain_setup(request)
        self.assertEqual(request.session.get('included_chains'), ['A'])
        self.assertEqual(request.session.get('removed_chains'), ['B'])
开发者ID:brcamor,项目名称:allostery-site,代码行数:16,代码来源:tests_all.py

示例9: render

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def render(self, context):
        request = context['request']

        # Make request.GET mutable.
        # request.GET = dict(request.GET)

        if self.var_name in request.GET:
            return ''
        else:
        	mydict = {self.var_name : 1}
        	qdict = QueryDict('')
        	qdict = request.GET.copy()
        	qdict.update(mydict)
        	request.GET = qdict
        	# request.GET[self.var_name] = 1
        	return self.nodelist.render(context)
开发者ID:NJMC,项目名称:Nialls-Repository,代码行数:18,代码来源:once.py

示例10: on_user_logged_out

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
def on_user_logged_out(sender, request, user, **kwargs):
    if not settings.AUTH_OPENID:
        return

    query = QueryDict('', mutable=True)
    query.update({
        'redirect_uri': settings.BASE_SITE_URL
    })

    openid_logout_url = "%s?%s" % (
        client.openid_connect_client.get_url(
            name='end_session_endpoint'),
        query.urlencode()
    )

    request.COOKIES['next'] = openid_logout_url
开发者ID:drunkcz,项目名称:jumpserver,代码行数:18,代码来源:signals_handlers.py

示例11: __init__

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def __init__(self, *args, **kwargs):
        newPosts = QueryDict("", True)
        if len(args) > 0:
            posts = dict(args[0].items())

            if posts["dlDate"] and posts["dlHour"] and posts["dlMin"]:
                posts["deadline"] = self.getDeadline(posts["dlDate"], posts["dlHour"], posts["dlMin"])

            if posts["terms"]:
                posts["term"] = posts["terms"]

            posts["identifier"] = self.randStr(20)

            newPosts.update(posts)
            super(EventForm, self).__init__((newPosts))
        else:
            super(EventForm, self).__init__(*args, **kwargs)
开发者ID:gm2bv,项目名称:mosi2map,代码行数:19,代码来源:models.py

示例12: merge_defaults

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
 def merge_defaults(self):
     if self.use_defaults:
         data = QueryDict('', mutable=True)
         if self.data:
             data.update(self.data)
         initial = self.initial_data
         for key in initial:
             if key in data:
                 continue
             value = initial[key]
             name = self.add_prefix(key)
             if value is not None:
                 if isinstance(value, (list, tuple)):
                     data.setlistdefault(name, value)
                 else:
                     data.setdefault(name, value)
         self.data = data
开发者ID:vivsh,项目名称:django-ginger,代码行数:19,代码来源:actions.py

示例13: read_raw_data

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
 def read_raw_data(self, request):
     # convert the data into the correct format and add
     # it as POST variables.
     from django.http.request import QueryDict, MultiValueDict
     if not request.method in ['POST', 'PUT']:
         request._post, request._files = QueryDict('', encoding=request._encoding), MultiValueDict()
     else:
         # TODO multipart (files) not supported.
         q = QueryDict('', encoding=request._encoding).copy()
         d = self._raw_data_to_dict(request)
         for key in d.keys():
             if isinstance(d[key], list):
                 q.setlist(key, d.pop(key))
         q.update(d)
         request.method = 'POST'
         request._post = q
         request._files = MultiValueDict()
开发者ID:danrex,项目名称:django-riv,代码行数:19,代码来源:resources.py

示例14: format_filter

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
 def format_filter(self, obj):
     qd = QueryDict(mutable=True)
     filter_fields = self.filter.keys()
     for field_name in filter_fields:
         try:
             # check if serializer method passed in
             serializer_method = getattr(self.parent, self.filter[field_name])
         except AttributeError:
             value = self.lookup_attribute(obj, self.filter[field_name])
         else:
             value = serializer_method(obj)
         if not value:
             continue
         qd.update({'[{}]'.format(field_name): value})
     if not qd.keys():
         return None
     return qd.urlencode(safe=['[', ']'])
开发者ID:monikagrabowska,项目名称:osf.io,代码行数:19,代码来源:serializers.py

示例15: test_source_setup_stores_source_residues_to_session_variable

# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import update [as 别名]
    def test_source_setup_stores_source_residues_to_session_variable(self):
        request = HttpRequest()
        request.method = 'POST'
        request.session = self.engine.SessionStore(None)
        request.session['pdb_id'] = '1SC1'
        request.session['chains'] = ['A', 'B']
        request.session['hetatms'] = [('PHQ', 'C', '1'), ('CF0', 'C', '5')]
        request.session['residue_list'] = [('125', 'A'), ('126', 'A')]
        
        _dict = {'residues' : '0'}
        _qdict = QueryDict('', mutable=True)
        _qdict.update(_dict)
        request.POST = _qdict

        response = source_setup(request)

        self.assertEqual(request.session.get('source_residues')[0], ('125', 'A'))
开发者ID:brcamor,项目名称:allostery-site,代码行数:19,代码来源:tests_all.py


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