The tw.tasks object is a TaskQuerySet that emulates the Django ORM API.
Common Retrieval Methods
.all(): Returns all tasks..pending(): Returns only pending tasks..completed(): Returns only completed tasks..get(**kwargs): Returns the single task matching the query. Raises tasklib.task.DoesNotExist if no task is found, or ValueError if more than one task matches.
Filtering Syntax
You can filter using keyword arguments (where __ is used for lookups) or by passing raw TaskWarrior command strings.
Note: Using raw commands is discouraged as it may reduce portability across TaskWarrior versions, but it is useful for syntax not yet supported by tasklib (e.g., virtual tags).
# Keyword filtering
tw.tasks.filter(status='pending', tags__contains=['work'])
# Raw command filtering
tw.tasks.filter('status:pending +work')
# Mixing raw commands and keywords
tw.tasks.filter('+BLOCKING', project='Home')
# Stacking filters
home_tasks = tw.tasks.filter(project='Wife')
results = home_tasks.filter(due__before=datetime(2015,2,14,14,14,14))