Re: What's the proper use of LazyDate?
On 1/5/07, James Bennett <[EMAIL PROTECTED]> wrote: I can't find it now, but I have this odd feeling that somewhere I saw mention that LazyDate was/would be/should be deprecated in favor of just using the appropriate methods from the datetime module (e.g., instead of using a LazyDate object as a default for a DateTimeField, use datetime.datetime.now, and so on). Or am I getting all confused again? The reference you are probably thinking of is the field_defaults modeltest. It doesn't mention LazyDate - it justs says that you could use datetime.now as a callable default value. The only place 'LazyDate' turns up is in the model API. datetime.now (passed as a callable) isn't a complete solution, though. You can't use a callable in a query argument - at least, not in the current implementation of queries. A similar problem exists for field initial values. I can't see any particular reason that a callable shouldn't be allowed just about anywhere in a model definition or query definition. It's just more work to allow it. But this would allow us to officially deprecate LazyDate (which appeals to me because of the number of times LazyDate has bitten me on the posterior testing bugfixes, etc). Anyone want to volunteer? Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What's the proper use of LazyDate?
On 05-Jan-07, at 1:34 PM, James Bennett wrote: Or am I getting all confused again? only the forces of evil get confused ;-) -- "May the forces of evil become confused on the way to your house." -- George Carlin -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What's the proper use of LazyDate?
On 1/4/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: There is a tangential reference to LazyDate in the model API documentation, but otherwise, this is an area where some documentation could be useful. I've opened a ticket (#3231) for this issue. I can't find it now, but I have this odd feeling that somewhere I saw mention that LazyDate was/would be/should be deprecated in favor of just using the appropriate methods from the datetime module (e.g., instead of using a LazyDate object as a default for a DateTimeField, use datetime.datetime.now, and so on). Or am I getting all confused again? -- "May the forces of evil become confused on the way to your house." -- George Carlin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: What's the proper use of LazyDate?
On 1/5/07, John DeRosa <[EMAIL PROTECTED]> wrote: What's the proper/recommended/improper/not-recommended use of models.LazyDate() in 0.95? I'm working on a project that picked up its use in 0.91-based code. There's a passing reference to it in the 0.90 docs, but nothing since then. There are references to it all over the web... E.g.: class UserReadComment(models.Model): scoop = models.ForeignKey(Scoop,raw_id_admin=True) [...snip...] last_read = models.DateTimeField(default=models.LazyDate(), auto_now=True) The purpose of LazyDate is to be a proxy around a date object that allows you to specify a date that won't be evaluated until it is used in a model. In your example, comment.last_read.day will return the day on which the instance was saved (similarly for other attributes of the date object). You can also provide arguments to the LazyDate that specify a timeDelta to apply; for example: limit_choices_to = {'date__gt' : models.LazyDate(days=-3)} would be a filter that keeps only those objects from the last three days. There is a tangential reference to LazyDate in the model API documentation, but otherwise, this is an area where some documentation could be useful. I've opened a ticket (#3231) for this issue. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
What's the proper use of LazyDate?
What's the proper/recommended/improper/not-recommended use of models.LazyDate() in 0.95? I'm working on a project that picked up its use in 0.91-based code. There's a passing reference to it in the 0.90 docs, but nothing since then. There are references to it all over the web... E.g.: class UserReadComment(models.Model): scoop = models.ForeignKey(Scoop,raw_id_admin=True) [...snip...] last_read = models.DateTimeField(default=models.LazyDate(), auto_now=True) ? John --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---