Skip to content

Instantly share code, notes, and snippets.

@cristianjs19
Last active June 3, 2020 04:53
Show Gist options
  • Save cristianjs19/500af529d5b76c9824a3bf6c65cc83fd to your computer and use it in GitHub Desktop.
Save cristianjs19/500af529d5b76c9824a3bf6c65cc83fd to your computer and use it in GitHub Desktop.
class Foo(models.Model):
status = models.CharField()
expiring_date = models.DateField()
def is_active(self):
today = datetime.date.today()
if today > self.expiring_date:
self.status = "expired"
self.save()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment