本文整理匯總了Python中models.Category.get_delete_url方法的典型用法代碼示例。如果您正苦於以下問題:Python Category.get_delete_url方法的具體用法?Python Category.get_delete_url怎麽用?Python Category.get_delete_url使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Category
的用法示例。
在下文中一共展示了Category.get_delete_url方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_delete
# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import get_delete_url [as 別名]
def test_delete(self):
title = "Vodka based"
category = Category(title=title)
category.save()
self.assertEqual(Category.objects.all().count(), 1)
url = category.get_absolute_url()
res = self.app.get(url)
del_url = category.get_delete_url()
res = self.app.get(del_url)
form = res.forms["delete_form"]
res = form.submit().follow()
self.assertEqual(Category.objects.all().count(), 0)
示例2: test_delete_with_coctails
# 需要導入模塊: from models import Category [as 別名]
# 或者: from models.Category import get_delete_url [as 別名]
def test_delete_with_coctails(self):
title = "Vodka based"
category = Category(title=title)
category.save()
Coctail(title="Pure vodka", category=category).save()
Coctail(title="Only vodka", category=category).save()
self.assertEqual(Category.objects.all().count(), 1)
self.assertEqual(Coctail.objects.all().count(), 2)
del_url = category.get_delete_url()
res = self.app.get(del_url)
form = res.forms["delete_form"]
res = form.submit().follow()
self.assertEqual(Category.objects.all().count(), 0)
self.assertEqual(Coctail.objects.all().count(), 0)