本文整理汇总了Python中django.http.request.QueryDict._encoding方法的典型用法代码示例。如果您正苦于以下问题:Python QueryDict._encoding方法的具体用法?Python QueryDict._encoding怎么用?Python QueryDict._encoding使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.http.request.QueryDict
的用法示例。
在下文中一共展示了QueryDict._encoding方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import _encoding [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
示例2: get_data
# 需要导入模块: from django.http.request import QueryDict [as 别名]
# 或者: from django.http.request.QueryDict import _encoding [as 别名]
def get_data(self):
if '@disable_auto_data' in self._data:
return self._data
if not hasattr(self, '_data_'):
self._data_ = self._data
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
for name, field in self.fields.items():
initial_value = None
prefixed_name = self.add_prefix(name)
data_value = field.widget.value_from_datadict(self._data_, self.files, prefixed_name)
if data_value is None:
if not field.show_hidden_initial:
initial_value = self.initial.get(name, field.initial)
if callable(initial_value):
initial_value = initial_value()
else:
initial_prefixed_name = self.add_initial_prefix(name)
hidden_widget = field.hidden_widget()
try:
initial_value = field.to_python(hidden_widget.value_from_datadict(
self.data, self.files, initial_prefixed_name))
except ValidationError:
# Always assume data has changed if validation fails.
self._changed_data.append(name)
continue
if callable(initial_value):
initial_value = initial_value()
if initial_value is not None:
self._data_[prefixed_name] = initial_value
return self._data_