本文整理汇总了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