本文整理匯總了Python中models.Document.doc_descr方法的典型用法代碼示例。如果您正苦於以下問題:Python Document.doc_descr方法的具體用法?Python Document.doc_descr怎麽用?Python Document.doc_descr使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Document
的用法示例。
在下文中一共展示了Document.doc_descr方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: listdocs
# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import doc_descr [as 別名]
def listdocs(request):
if request.method == 'GET':
# retrieve and display all documents
all_docs = Document.objects.filter(
user_name=request.user).order_by('doc_ul_date')
return render_to_response(
'jobtracker/listdocums.html', {
'all_docs': all_docs,
'username': request.user.username
},
context_instance=RequestContext(request))
# posting corresponds to uploading a document
elif request.method == 'POST':
# all fields must have been entered
try:
newdoc = Document()
newdoc.doc_descr = request.POST['doc_descr']
newdoc.doc_type = request.POST['doc_type']
newdoc.the_doc = request.FILES['the_doc']
newdoc.doc_mime = request.FILES['the_doc'].content_type
except:
# display the error
all_docs = Document.objects.filter(
user_name=request.user).order_by('doc_ul_date')
return render_to_response(
'jobtracker/listdocums.html', {
'all_docs': all_docs,
'username': request.user.username,
'error_message': "You did not enter all required data"
},
context_instance=RequestContext(request))
else:
curruser = User.objects.get(username=request.user.username)
newdoc.user_name = curruser
newdoc.save()
all_docs = Document.objects.filter(
user_name=request.user).order_by('doc_ul_date')
return redirect('/document/')
else:
raise Http404