Re: Forms problem?
Scott, that was the hint I needed. I had a default value of datetime.date.today instead of datetime.datetime.now. Strangely enough, the problem only manifested itself from within the admin interface, the ModelForms worked fine. Thanks, Greg On Aug 28, 11:40 am, "Scott Moonen" <[EMAIL PROTECTED]> wrote: > Greg, it looks to me like you are storing a date value into a datetime > field. Consider the error: > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line 662, > > > in decompress > > return [value.date(), value.time().replace(microsecond=0)] > > > AttributeError: 'datetime.date' object has no attribute 'date' > > The Django code is trying to peel away the date and time values from the > value in the form field. But evidently the form field contains a > datetime.date, whereas Django is expecting a datetime.datetime. Does that > make sense? Perhaps you are passing in something like > "datetime.date.today()" where you should be passing in something like > "datetime.datetime.now()". Or else maybe your field really should be a date > field instead of a datetime field? > > -- Scott > > On Thu, Aug 28, 2008 at 11:35 AM, Greg Taylor <[EMAIL PROTECTED]>wrote: > > > > > > > Thanks for the tip. I replaced all of my from datetime import datetime > > istances, but it looks like this is still happening. The problem only > > manifested itself when I updated to the latest trunk. I was previously > > running a few revisions earlier than the signals refactoring. If you > > have any other ideas, I'm all ears, this is a bit of a showstopper for > > me. > > > Thanks! > > Greg > > > On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> > > wrote: > > > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > > > I'm getting the following error on some of my models with > > > > DateTimeFields. Any ideas? > > > > > Traceback (most recent call last): > > > > ... snip. ... > > > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > > > 662, in decompress > > > > return [value.date(), value.time().replace(microsecond=0)] > > > > > AttributeError: 'datetime.date' object has no attribute 'date' > > > > This probably means that somewhere in your code you've done "from > > > datetime import datetime" rather than just "import datetime". > > > Annoyingly and confusingly, both the module and one of its classes are > > > called datetime. The *module* 'datetime' does have an attribute called > > > 'date', but the *class* 'datetime' does not. > > > > Basically, unless you have a very good reason, you should always use > > > "import datetime". > > > -- > > > DR. > > --http://scott.andstuff.org/|http://truthadorned.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?hl=en -~--~~~~--~~--~--~---
Re: Forms problem?
Greg, it looks to me like you are storing a date value into a datetime field. Consider the error: File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line 662, > in decompress > return [value.date(), value.time().replace(microsecond=0)] > > AttributeError: 'datetime.date' object has no attribute 'date' > The Django code is trying to peel away the date and time values from the value in the form field. But evidently the form field contains a datetime.date, whereas Django is expecting a datetime.datetime. Does that make sense? Perhaps you are passing in something like "datetime.date.today()" where you should be passing in something like "datetime.datetime.now()". Or else maybe your field really should be a date field instead of a datetime field? -- Scott On Thu, Aug 28, 2008 at 11:35 AM, Greg Taylor <[EMAIL PROTECTED]>wrote: > > Thanks for the tip. I replaced all of my from datetime import datetime > istances, but it looks like this is still happening. The problem only > manifested itself when I updated to the latest trunk. I was previously > running a few revisions earlier than the signals refactoring. If you > have any other ideas, I'm all ears, this is a bit of a showstopper for > me. > > Thanks! > Greg > > On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> > wrote: > > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > > > I'm getting the following error on some of my models with > > > DateTimeFields. Any ideas? > > > > > Traceback (most recent call last): > > > > ... snip. ... > > > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > > 662, in decompress > > >return [value.date(), value.time().replace(microsecond=0)] > > > > > AttributeError: 'datetime.date' object has no attribute 'date' > > > > This probably means that somewhere in your code you've done "from > > datetime import datetime" rather than just "import datetime". > > Annoyingly and confusingly, both the module and one of its classes are > > called datetime. The *module* 'datetime' does have an attribute called > > 'date', but the *class* 'datetime' does not. > > > > Basically, unless you have a very good reason, you should always use > > "import datetime". > > -- > > DR. > > > -- http://scott.andstuff.org/ | http://truthadorned.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?hl=en -~--~~~~--~~--~--~---
Re: Forms problem?
Thanks for the tip. I replaced all of my from datetime import datetime istances, but it looks like this is still happening. The problem only manifested itself when I updated to the latest trunk. I was previously running a few revisions earlier than the signals refactoring. If you have any other ideas, I'm all ears, this is a bit of a showstopper for me. Thanks! Greg On Aug 28, 10:31 am, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > > > I'm getting the following error on some of my models with > > DateTimeFields. Any ideas? > > > Traceback (most recent call last): > > ... snip. ... > > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > > 662, in decompress > > return [value.date(), value.time().replace(microsecond=0)] > > > AttributeError: 'datetime.date' object has no attribute 'date' > > This probably means that somewhere in your code you've done "from > datetime import datetime" rather than just "import datetime". > Annoyingly and confusingly, both the module and one of its classes are > called datetime. The *module* 'datetime' does have an attribute called > 'date', but the *class* 'datetime' does not. > > Basically, unless you have a very good reason, you should always use > "import datetime". > -- > DR. --~--~-~--~~~---~--~~ 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: Forms problem?
On Aug 28, 3:01 pm, Greg Taylor <[EMAIL PROTECTED]> wrote: > I'm getting the following error on some of my models with > DateTimeFields. Any ideas? > > Traceback (most recent call last): > ... snip. ... > > File "/home/clemsoncrew/site-packages/django/forms/widgets.py", line > 662, in decompress > return [value.date(), value.time().replace(microsecond=0)] > > AttributeError: 'datetime.date' object has no attribute 'date' This probably means that somewhere in your code you've done "from datetime import datetime" rather than just "import datetime". Annoyingly and confusingly, both the module and one of its classes are called datetime. The *module* 'datetime' does have an attribute called 'date', but the *class* 'datetime' does not. Basically, unless you have a very good reason, you should always use "import datetime". -- DR. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---