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


Python Document.delete方法代碼示例

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


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

示例1: executeUpload

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import delete [as 別名]
def executeUpload(request):
    # Save the files
    form = DocumentForm(request.POST, request.FILES)
    
    file_new = request.FILES['docfile']
    
    if form.is_valid():
        #Save temporary file
        newdoc = Document(docfile = file_new)
        newdoc.save()
    
        fn = file_new.name
        fn = fn.replace (" ", "_")
    
        #Move the file to the new folder
        src = os.path.join(django_settings.FILE_UPLOAD_TEMP_DIR, 'uploads', fn)
        file_upload = src
        path = os.path.join(request.session['projectPath'],'Uploads')
        target = os.path.join(path, fn)
        if os.path.exists(target):
            os.remove(target)
        shutil.move(src, path)
        
        #Delete the temporary file
        newdoc.delete()
開發者ID:I2PC,項目名稱:scipion,代碼行數:27,代碼來源:views_management.py

示例2: test_add_doc

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import delete [as 別名]
 def test_add_doc(self):
     # Add a document to the repo
     doc = Document.objects.create(docid='mydoc', repo=self.repo)
     # Query repo
     qds = self.repo.docs.filter(docid='mydoc')
     # Remove document from repo
     Document.delete(qds.first())
開發者ID:HazyResearch,項目名稱:elementary,代碼行數:9,代碼來源:tests.py

示例3: test_model_document

# 需要導入模塊: from models import Document [as 別名]
# 或者: from models.Document import delete [as 別名]
 def test_model_document(self):
     """Test Document Model"""
     folder = Folder(name='test')
     folder.save()
     obj = Document(title='test', folder=folder)
     obj.save()
     self.assertEquals(folder, obj.folder)
     self.assertNotEquals(obj.id, None)
     obj.delete()
開發者ID:tovmeod,項目名稱:anaf,代碼行數:11,代碼來源:tests.py


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