本文整理汇总了Python中forms.UploadFileForm.fields['serial_number']方法的典型用法代码示例。如果您正苦于以下问题:Python UploadFileForm.fields['serial_number']方法的具体用法?Python UploadFileForm.fields['serial_number']怎么用?Python UploadFileForm.fields['serial_number']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forms.UploadFileForm
的用法示例。
在下文中一共展示了UploadFileForm.fields['serial_number']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: new
# 需要导入模块: from forms import UploadFileForm [as 别名]
# 或者: from forms.UploadFileForm import fields['serial_number'] [as 别名]
def new(request):
errorMessage = None
activatedKeys = Product.objects.filter(client=request.user,activated=True).values_list('serial','serial')
if (request.POST):
form = UploadFileForm(request.POST, request.FILES)
form.fields['serial_number'] = forms.ChoiceField(choices = activatedKeys )
if form.is_valid():
#import rpdb2
#rpdb2.start_embedded_debugger("1")
b = Backup()
b.user = request.user
b.file=form.cleaned_data['file']
b.mime = request.FILES['file'].content_type
b.size = request.FILES['file'].size
#b.etva_agent = form.cleaned_data['etva_agent']
b.file_name = (form.cleaned_data['file']).name
b.notes=form.cleaned_data['notes']
b.product=Product.objects.get(serial=form.cleaned_data['serial_number'],client=request.user,activated=True)
b.save()
return HttpResponseRedirect('/backups/') # Redirect after POST
else:
form = UploadFileForm()
form.fields['serial_number'] = forms.ChoiceField(choices = activatedKeys)
return render_to_response('backup/new.html',
{
'form':form,
'section':SECTION_BACKUPS,
'errorMessage':errorMessage,
'activatedKeys':activatedKeys,
},context_instance=RequestContext(request))