This manager is intended for use with models with publication and/or expiration dates. Objects will be retrieved only if their publication and/or expiration dates are within the current date.
Use is very simple:
class ExampleModel(models.Model):
publish_date = models.DateTimeField()
expire_date = models.DateTimeField(blank=True, null=True)
objects = models.Manager()
actives = ActiveManager(from_date='publish_date', to_date='expire_date')
ExampleModel.actives.all() # retrieve active objects according to the current date
The manager works correctly with nullable date fields. A null publication date means "*always published (until expiration date)*" and a null expiration date means "*never expires*".
Most models should define the `objects` manager as the default manager, because otherwise out of date objects won't appear in the admin app.
- model
- manager
- active
- publication
- expiration
- date-filter