I made this suggestion on the django board.
@auto_now('updatted_on')
@auto_add_now('submitted_date')
def save(self):
super(MyModel).save()
I even have started coding it as I need SOME solution that is simple.
One problem I have had is with edit_inline and auto_now where the
entries are
+1. Follows DRY. An AutoDateTimeField is very common.
j
On 4/6/07, Jacob Kaplan-Moss <[EMAIL PROTECTED]> wrote:
>
>
> > seems like it should be as easy as a function in contrib somewhere:
> [snip]
>
> Another option is a trivial field subclass::
>
> class
> seems like it should be as easy as a function in contrib somewhere:
[snip]
Another option is a trivial field subclass::
class AutoDateTimeField(models.DateTimeField):
def pre_save(self, model_instance, add):
return datetime.datetime.now()
Jacob
On Apr 6, 2007, at 11:39 AM, David Larlet wrote:
>
> 2007/4/6, Brian Beck <[EMAIL PROTECTED]>:
>>
>> On Apr 2, 12:52 pm, "trbs" <[EMAIL PROTECTED]> wrote:
>>> It could be just me, but although i don't mind losing auto_*, it
>>> don't
>>> look very DRY in save.
>>>
>>> I know it's only a few
Did people feel that save() was a better solution because it's already
a place where you have to put equivalent functionality for other
fields? I don't know why, but defining my own save() always seems like
a "big deal" that should be reserved for more complex stuff.
What about a new attribute
2007/4/6, Brian Beck <[EMAIL PROTECTED]>:
>
> On Apr 2, 12:52 pm, "trbs" <[EMAIL PROTECTED]> wrote:
> > It could be just me, but although i don't mind losing auto_*, it don't
> > look very DRY in save.
> >
> > I know it's only a few lines (like 4 ? for both options, not using
> > default= for
On Apr 2, 12:52 pm, "trbs" <[EMAIL PROTECTED]> wrote:
> It could be just me, but although i don't mind losing auto_*, it don't
> look very DRY in save.
>
> I know it's only a few lines (like 4 ? for both options, not using
> default= for sake of keeping the logic together) but when lots of
>
On Apr 2, 2:50 am, "Adrian Holovaty" <[EMAIL PROTECTED]> wrote:
> On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
>
> > I'm not sure if there's a ticket for this, but I remember talk about
> > it being an unnecessary wart which was going to be removed eventually.
> > Is it in the 1.0 plan?
>
>
On 4/2/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> > I'm not sure if there's a ticket for this, but I remember talk about
> > it being an unnecessary wart which was going to be removed eventually.
> > Is it in the 1.0 plan?
>
> Yes, I'd
On Mon, 2007-04-02 at 09:21 +0800, Russell Keith-Magee wrote:
> On 4/2/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> >
> > Is there an easy way to say "today - 3 days" just using the datetime
> > module? I can't think of one off the top of my head that isn't as
> > complex as LazyDate(),
On Mon, 2007-04-02 at 11:11 +1000, Malcolm Tredinnick wrote:
[...]
> At the moment LazyDate is useful in limit_choices_to and as a default
> value.
Scrub that last part. Wishful thinking on my part. It can't really be
used as a default at the moment, because it doesn't have a __call__
method.
On 4/2/07, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
>
> Is there an easy way to say "today - 3 days" just using the datetime
> module? I can't think of one off the top of my head that isn't as
> complex as LazyDate(), but that may be because it's Monday.
How about:
lambda : datetime.now()
On Mon, 2007-04-02 at 09:00 +0800, Russell Keith-Magee wrote:
> On 4/2/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
> >
> > On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> > > I'm not sure if there's a ticket for this, but I remember talk about
> > > it being an unnecessary wart which was
On 4/1/07, Russell Keith-Magee <[EMAIL PROTECTED]> wrote:
> What about LazyDate? It seems to me that given
> "default=datetime.datetime.now" is legal, LazyDate can be deprecated
> as well.
Yeah, I'd like to get rid of LazyDate, too.
Jacob
--~--~-~--~~~---~--~~
On 4/2/07, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> > I'm not sure if there's a ticket for this, but I remember talk about
> > it being an unnecessary wart which was going to be removed eventually.
> > Is it in the 1.0 plan?
>
> Yes, I'd
On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> I'm not sure if there's a ticket for this, but I remember talk about
> it being an unnecessary wart which was going to be removed eventually.
> Is it in the 1.0 plan?
Oh, please, yes!
I'd be inclined just to remove 'em wholesale and let things
On 4/1/07, SmileyChris <[EMAIL PROTECTED]> wrote:
> I'm not sure if there's a ticket for this, but I remember talk about
> it being an unnecessary wart which was going to be removed eventually.
> Is it in the 1.0 plan?
Yes, I'd like to drop those two options.
auto_now can be accomplished with
I'm not sure if there's a ticket for this, but I remember talk about
it being an unnecessary wart which was going to be removed eventually.
Is it in the 1.0 plan?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
18 matches
Mail list logo