Is there an equivalent of AR's named scopes? Named scopes are basically filters, that can be wrapped in a method, and then chained.
Here's an example from http://archives.ryandaigle.com/articles/2008/8/20/named-scope-it-s-not-just-for-conditions-ya-know:
class Article < ActiveRecord::Base
# Get all articles that have been published
named_scope :published, :conditions => ['published = ?', true]
# Get all articles that were created recently
named_scope :recent, lambda { { :conditions => ['created_at >= ?', 1.week.ago] } }
end
# Get all recently created articles that have been published
Article.published.recent
Here's an example using Django ORM: http://furrybrains.com/2009/06/22/named-scopes-for-django/