Re: auto_now_add bug with MySQL
On 5/29/06, Konstantin Shaposhnikov <[EMAIL PROTECTED]> wrote: > I've seen it here http://code.djangoproject.com/ticket/1056 (see the > first comment by jacob) > Though I am not sure how actual this statement is. Ticket seems to be quite > old. Luke fixed the code in the meantime though. It will still be interesting to get some feedback on the point above. -- Jeroen Ruigrok van der Werven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
On 5/29/06, Jeroen Ruigrok van der Werven <[EMAIL PROTECTED]> wrote: > Hi Konstantin, > > On 5/29/06, Konstantin Shaposhnikov <[EMAIL PROTECTED]> wrote: > > I suggest you to not use auto_now_add at all if you are using current > > (post magic-removal) version of django. > > I am using the SVN trunk yes. (It would be great if someone could > finally fix trunk's setup.py to reflect what manage.py states about > versioning.) > > [snip excellent suggestion] > > > 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. > > I couldn't find such statement quickly, so if anyone can please update > the list on this issue, thanks. I've seen it here http://code.djangoproject.com/ticket/1056 (see the first comment by jacob) Though I am not sure how actual this statement is. Ticket seems to be quite old. > Thanks Konstantin, I will play around with that. > > -- > Jeroen Ruigrok van der Werven > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
auto_now_add has been fixed in [3002] Hurray for Luke ;) -- Petar Marić *e-mail: [EMAIL PROTECTED] *mobile: +381 (64) 6122467 *icq: 224720322 *skype: petar_maric *web: http://www.petarmaric.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
Hi Konstantin, On 5/29/06, Konstantin Shaposhnikov <[EMAIL PROTECTED]> wrote: > I suggest you to not use auto_now_add at all if you are using current > (post magic-removal) version of django. I am using the SVN trunk yes. (It would be great if someone could finally fix trunk's setup.py to reflect what manage.py states about versioning.) [snip excellent suggestion] > 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. I couldn't find such statement quickly, so if anyone can please update the list on this issue, thanks. Thanks Konstantin, I will play around with that. -- Jeroen Ruigrok van der Werven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
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? -- Jeroen Ruigrok van der Werven --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
On 5/5/06, Petar Mariæ <[EMAIL PROTECTED]> wrote: > class Paper(models.Model): > # ... > submited_on = models.DateField( > auto_now_add=True, > ) > # ... > > The above will spit out: > Exception Type: ValueError > Exception Value:year is out of range > Exception Location: > C:\Dev\Python24\lib\site-packages\MySQLdb\connections.py in > defaulterrorhandler, line 33 > > The saved value of submited_on for the corresponding Paper is > '-00-00' which is horribly wrong ;) > > I'm using MySQL 4.1.12a-nt and freshly baked django svn copy Try the patch on this bug: http://code.djangoproject.com/ticket/1584 -- The Pythonic Principle: Python works the way it does because if it didn't, it wouldn't be Python. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
Fernando, It looks it's my own fault I failed to mention I was adding a new object via Djangos admin interface. That means it's Djangos fault, not mine ;) -- Petar Marić *e-mail: [EMAIL PROTECTED] *mobile: +381 (64) 6122467 *icq: 224720322 *skype: petar_maric *web: http://www.petarmaric.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Re: auto_now_add bug with MySQL
Petar, how was your object added? I had that problem when using the create function and save, for example using the model: class B(models.Model): date = models.DateField(auto_now_add=True) a = models.ForeignKey(A) doing this considering "object" is an object of class A, this produces the error, object.b_set.create().save() but: object.b_set.create() does the trick, i think that the first one shouldn't be used, i left it like that while changing code to use the Magic-Removal version of django. I hope this also helps you. -- Fernando Gutierrez H. http://www.aureal.com.pe Petar Marić wrote: > class Paper(models.Model): > # ... > submited_on = models.DateField( > auto_now_add=True, > ) > # ... > > The above will spit out: > Exception Type: ValueError > Exception Value: year is out of range > Exception Location: > C:\Dev\Python24\lib\site-packages\MySQLdb\connections.py in > defaulterrorhandler, line 33 > > The saved value of submited_on for the corresponding Paper is > '-00-00' which is horribly wrong ;) > > I'm using MySQL 4.1.12a-nt and freshly baked django svn copy > -- > Petar Marić > *e-mail: [EMAIL PROTECTED] > *mobile: +381 (64) 6122467 > > *icq: 224720322 > *skype: petar_maric > *web: http://www.petarmaric.com/ > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
auto_now_add bug with MySQL
class Paper(models.Model): # ... submited_on = models.DateField( auto_now_add=True, ) # ... The above will spit out: Exception Type: ValueError Exception Value:year is out of range Exception Location: C:\Dev\Python24\lib\site-packages\MySQLdb\connections.py in defaulterrorhandler, line 33 The saved value of submited_on for the corresponding Paper is '-00-00' which is horribly wrong ;) I'm using MySQL 4.1.12a-nt and freshly baked django svn copy -- Petar Marić *e-mail: [EMAIL PROTECTED] *mobile: +381 (64) 6122467 *icq: 224720322 *skype: petar_maric *web: http://www.petarmaric.com/ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---