Created
February 24, 2011 20:33
-
-
Save craigds/842832 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# sample code as a suggestion for https://convore.com/django-community/how-to-make-an-automatic-status-change/ | |
from datetime import datetime | |
class MyManager(models.Manager): | |
def active(self): | |
return self.get_query_set().filter(expires_at__gt=datetime.now()) | |
class MyClass(models.Model): | |
created_at = models.DateTimeField(auto_now_add=True, db_index=True) | |
expires_at = models.DateTimeField(db_index=True) | |
@property | |
def active(self): | |
return self.expires_at > datetime.now() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment