當前位置: 首頁>>代碼示例>>Python>>正文


Python Document.id方法代碼示例

本文整理匯總了Python中models.Document.id方法的典型用法代碼示例。如果您正苦於以下問題:Python Document.id方法的具體用法?Python Document.id怎麽用?Python Document.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在models.Document的用法示例。


在下文中一共展示了Document.id方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: add_clue

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import id [as 別名]
def add_clue(request):
    if request.method == 'POST':
        newdoc = Document(docfile=request.FILES.get('file', False))
        if newdoc.docfile:
            newdoc.id = str(request.FILES.get('file').name)
            newdoc.save()
            request.session['file'] = newdoc

        return render_to_response(
            'clue.html',
            {'image': request.session.get('file')},
            context_instance=RequestContext(request)
        )
開發者ID:sumehta,項目名稱:gps-estimation,代碼行數:15,代碼來源:views.py

示例2: list

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import id [as 別名]
def list(request):
    # Handle file upload
    # del request.session['file']
    # Document.objects.all().delete()
    if request.method == 'POST':
        # request.session['file'] = request.FILES.get('file', False)
        newdoc = Document(docfile=request.FILES.get('file', False))
        if newdoc.docfile:
            newdoc.id = str(request.FILES.get('file').name)
            newdoc.save()
            request.session['file'] = newdoc

        # # Redirect to the document list after POST
        matches = get_matches(str(request.FILES.get('file').name))
        if len(matches)>20:
            matches = matches[:20]
        matched_images = []
        matched_image_names = []
        for im_name in matches:
            matched_images.append(Image.objects.get(pk=im_name))
            matched_image_names.append(im_name)

        request.session['matches'] = matched_images
        store_location_information(request, matched_image_names)
        return HttpResponseRedirect(reverse('contextslices.photo.views.search'))


    if request.method == 'GET':
        matched_images = []
        if request.session.get('file'):
            matches = get_matches(request.session.get('file').id)

            if len(matches) > 20:
                matches = matches[:20]
                matched_images = []
                matched_image_names = []
                for im_name in matches:
                    matched_images.append(Image.objects.get(pk=im_name))
                    matched_image_names.append(im_name)
                request.session['matches'] = matched_images
                store_location_information(request, matched_image_names)

        return render_to_response(
            'results.html',
            {'file': request.session.get('file'), 'matches': matched_images, 'num_results': len(matched_images)},
            context_instance=RequestContext(request)
        )
開發者ID:sumehta,項目名稱:gps-estimation,代碼行數:49,代碼來源:views.py


注:本文中的models.Document.id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。