本文整理汇总了Python中tasks.models.Task.get_project_count方法的典型用法代码示例。如果您正苦于以下问题:Python Task.get_project_count方法的具体用法?Python Task.get_project_count怎么用?Python Task.get_project_count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tasks.models.Task
的用法示例。
在下文中一共展示了Task.get_project_count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: project_task_count
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import get_project_count [as 别名]
def project_task_count(context, project, asvar=None):
val = Task.get_project_count(project)
if asvar:
context[asvar] = val
return ""
else:
return val
示例2: your_projects
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import get_project_count [as 别名]
def your_projects(request, template_name="projects/your_projects.html"):
projects = Project.objects.filter(member_users=request.user).order_by("name")
content_type = ContentType.objects.get_for_model(Project)
projects = projects.extra(select=SortedDict([
("member_count", MEMBER_COUNT_SQL),
("topic_count", TOPIC_COUNT_SQL),
]), select_params=(content_type.id,))
from tasks.models import Task
for project in projects:
project.task_count = Task.get_project_count(project)
return render_to_response(template_name, {
"projects": projects,
}, context_instance=RequestContext(request))
示例3: projects
# 需要导入模块: from tasks.models import Task [as 别名]
# 或者: from tasks.models.Task import get_project_count [as 别名]
def projects(request, template_name="projects/projects.html"):
projects = Project.objects.all()
search_terms = request.GET.get("search", "")
if search_terms:
projects = (projects.filter(name__icontains=search_terms) |
projects.filter(description__icontains=search_terms))
content_type = ContentType.objects.get_for_model(Project)
projects = projects.extra(select=SortedDict([
("member_count", MEMBER_COUNT_SQL),
("topic_count", TOPIC_COUNT_SQL),
]), select_params=(content_type.id,))
from tasks.models import Task
for project in projects:
project.task_count = Task.get_project_count(project)
return render_to_response(template_name, {
"projects": projects,
"search_terms": search_terms,
}, context_instance=RequestContext(request))