Created
December 3, 2012 13:59
-
-
Save jjangdm/4195210 to your computer and use it in GitHub Desktop.
money class
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
class Money(models.Model): | |
date = models.DateField() | |
week = models.IntegerField(blank=True) | |
def save(self, *args, **kwargs): | |
if not self.week: | |
self.week = self.date.isocalendar()[1] | |
return super(Money, self).save(*args, **kwargs) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment