本文整理汇总了Python中models.Task.clean方法的典型用法代码示例。如果您正苦于以下问题:Python Task.clean方法的具体用法?Python Task.clean怎么用?Python Task.clean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Task
的用法示例。
在下文中一共展示了Task.clean方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: clean
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import clean [as 别名]
def clean(self):
cleaned_data = super(CreateTaskForm, self).clean()
task = Task(user=self.user, name=cleaned_data.get('name'), whitelist=cleaned_data.get('whitelist'),
blacklist=cleaned_data.get('blacklist'), max_links=cleaned_data.get('max_links'),
expire_date=cleaned_data.get('expire'), priority=cleaned_data.get('priority'),
mime_type=cleaned_data.get('mime_type'), start_links=cleaned_data.get('start_links'))
try:
task.clean()
except QuotaException as e:
raise ValidationError(e.message)
return self.cleaned_data
示例2: test_priority_default
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import clean [as 别名]
def test_priority_default(self):
"""Test that the priority is taken from category if needed"""
# create task with explicit priority
explicit_task = Task(
category = self.high_priority_category,
priority = 5,
)
explicit_task.clean()
self.assertEqual( explicit_task.priority, 5 )
# create task with default priority
defaulted_task = Task(
category = self.high_priority_category,
)
defaulted_task.clean()
self.assertEqual( defaulted_task.priority, self.high_priority_category.priority )