Ticket #1414: lazydate-attributes.diff
File lazydate-attributes.diff, 789 bytes (added by , 19 years ago) |
---|
-
magic-removal/django/db/models/__init__.py
27 27 def __init__(self, **kwargs): 28 28 self.delta = datetime.timedelta(**kwargs) 29 29 30 def __str__(self):31 return str(self.__get_value__())32 33 30 def __repr__(self): 34 31 return "<LazyDate: %s>" % self.delta 35 32 36 33 def __get_value__(self): 37 34 return datetime.datetime.now() + self.delta 35 36 def __getattr__(self, attr): 37 """ 38 Catch missing attributes and serve them from the datetime 39 calculated at run time. 40 """ 41 return getattr(self.__get_value__(), attr)