本文整理匯總了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()
示例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())
示例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()