本文整理汇总了Python中models.Record.get_fieldvalues方法的典型用法代码示例。如果您正苦于以下问题:Python Record.get_fieldvalues方法的具体用法?Python Record.get_fieldvalues怎么用?Python Record.get_fieldvalues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Record
的用法示例。
在下文中一共展示了Record.get_fieldvalues方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: record
# 需要导入模块: from models import Record [as 别名]
# 或者: from models.Record import get_fieldvalues [as 别名]
#.........这里部分代码省略.........
def clean_context_type(self):
context = self.cleaned_data.get('context_type')
if context:
context = ContentType.objects.get(id=context)
return context
def clean(self):
cleaned_data = self.cleaned_data
return cleaned_data
field = forms.ChoiceField(choices=_field_choices())
value = forms.CharField(widget=forms.Textarea, required=False)
context_type = forms.IntegerField(
widget=forms.HiddenInput, required=False)
context_id = forms.IntegerField(
widget=forms.HiddenInput, required=False)
index_value = forms.CharField(
widget=forms.HiddenInput, required=False)
browse_value = forms.CharField(
widget=forms.HiddenInput, required=False)
class Meta:
model = FieldValue
fields = "__all__"
class CollectionForm(forms.Form):
id = forms.IntegerField(widget=forms.HiddenInput)
title = forms.CharField(widget=DisplayOnlyTextWidget)
member = forms.BooleanField(required=False)
shared = forms.BooleanField(required=False)
fieldvalues_readonly = []
if customize or context:
fieldvalues = record.get_fieldvalues(
owner=request.user, context=context, hidden=True
).filter(owner=request.user)
else:
fieldvalues = record.get_fieldvalues(hidden=True)
field_value_formset = modelformset_factory(
FieldValue,
form=FieldValueForm,
fields=FieldValueForm.Meta.fields,
can_delete=True,
extra=3
)
collection_formset = formset_factory(CollectionForm, extra=0)
if request.method == 'POST':
formset = field_value_formset(
request.POST, request.FILES, queryset=fieldvalues, prefix='fv')
if not (customize or context):
collectionformset = collection_formset(
request.POST, request.FILES, prefix='c')
else:
collectionformset = None
if formset.is_valid() and (
customize or context or collectionformset.is_valid()):
record.save()
if not (customize or context):
collections = dict(
(c['id'], c)
for c in collectionformset.cleaned_data