djangosnippets.org: Latest snippets tagged with 'expiration'https://djangosnippets.org/tags/expiration/2008-08-01T08:10:35.518610-05:00Expire page from cache
2008-08-01T08:10:35.518610-05:00mattgraysonhttps://djangosnippets.org/snippets/936/<p>A simple helper function that clears the cache for a given URL, assuming no headers. Probably best used when wired up to a model's post_save event via signals. See <a href="http://groups.google.com/group/django-users/msg/b077ec2e97697601">message to django-users mailing list</a> for background.</p>
Freely redistributableActiveManager: filter objects depending on publication and/or expiration dates
2008-07-01T05:31:22.869286-05:00haplohttps://djangosnippets.org/snippets/838/<p>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.</p>
<p>Use is very simple:</p>
<pre><code>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() …</code></pre>
Freely redistributable