Hello,

On 5/29/06, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> wrote:
> Andy,
>
> On 5/8/06, Andy Dustman <[EMAIL PROTECTED]> wrote:
> > Try the patch on this bug:
>
> The 2nd patch didn't work for me, as I noted in the ticket.
>
> The initial save with DateField(auto_now_add = True) is correct, it
> has the date as it should. But using it in conjunction with
> FileField() will cause an automatic UPDATE statement to happen and,
> 'lo and behold, the DateField is now None and thus violating the
> constraint.
>
> I can understand the logic of doing an UPDATE, but I wonder what to do
> with the date. Perhaps make sure the value of the date stamp is kept
> and passed in the UPDATE again?

I suggest you to not use auto_now_add at all if you are using current
(post magic-removal) version of django.
Instead declare your field like this:

  import datetime
  ...
  date_field = DateField(default = datetime.datetime.now, editable = False)

It has the same effect as auto_now_add and work with FileFields perfectly.

If you what to implement auto_now field, just override save() method
and set field value to current time before calling models.Model.save()

I am not really sure, but I seen somewhere that auto_now and
auto_now_add are going to become deprecated and it makes sense taking
into account that it is possible to achieve given functionlaity in
other way and code that supports auto_now[_add] is full of hacks.

> --
> Jeroen Ruigrok van der Werven
>
> >
>

Reagrds,
Konstantin
-- 
http://step-inside.org

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to