changeset 3960 broke something with DateTimeField's

2 views
Skip to first unread message

Matthew Flanagan

unread,
Nov 6, 2006, 1:49:47 AM11/6/06
to django-d...@googlegroups.com
Hi,

I'm using postgres DB with the following model:

class Contact(models.Model):
"""
Contact details for a person, role, organization or org unit.
"""
name = models.CharField(maxlength=128, db_index=True)
organisation = models.CharField(maxlength=128, blank=True)
department = models.CharField(maxlength=128, blank=True)
phone1 = models.CharField(maxlength=16, blank=True)
phone2 = models.CharField(maxlength=16, blank=True)
phone3 = models.CharField(maxlength=16, blank=True)
email = models.EmailField(blank=True)
web_site = models.URLField(blank=True)
# from old Addressee model
address1 = models.CharField(maxlength=64, blank=True, core=True)
address2 = models.CharField(maxlength=64, blank=True)
address3 = models.CharField(maxlength=64, blank=True)
address4 = models.CharField(maxlength=64, blank=True)
city = models.CharField(maxlength=64, blank=True)
state = models.CharField(maxlength=32, blank=True)
post_code = models.CharField(maxlength=16, blank=True)
country = models.CharField(maxlength=64, blank=True)
# Audit fields
created = models.DateTimeField('created', default=models.LazyDate(),
blank=True)
created_by = models.ForeignKey(User, verbose_name='created by',
related_name='directory_contact_created_by', blank=True)
changed = models.DateTimeField('last changed', auto_now=True)
changed_by = models.ForeignKey(User, verbose_name='last changed by',
related_name='directory_contact_changed_by', blank=True)

When I try and create a Contact and save it I get the following error.
This worked fine up until r3960 was checked in a few days ago.

>>> from nong.directory.models import Contact
>>>Contact(name='foo').save()
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/xxx/django/django/db/models/base.py", line 204, in save
','.join(placeholders)), db_values)
File "/xxx/django/django/db/backends/util.py", line 12, in execute
return self.cursor.execute(sql, params)
psycopg.ProgrammingError: ERROR: column "created" is of type
timestamp with time zone but expression is of type integer
HINT: You will need to rewrite or cast the expression.

INSERT INTO "directory_contact"
("name","organisation","department","phone1","phone2","phone3","email","web_site","address1","address2","address3","address4","city","state","post_code","country","created","created_by_id","changed","changed_by_id")
VALUES ('foo','','','','','','','','','','','','','','','',2006-11-06,NULL,'2006-11-06
17:44:37.445033',NULL)

regards

matthew

Russell Keith-Magee

unread,
Nov 6, 2006, 2:02:43 AM11/6/06
to django-d...@googlegroups.com
On 11/6/06, Matthew Flanagan <mattim...@gmail.com> wrote:
>
> Hi,

>
> When I try and create a Contact and save it I get the following error.
> This worked fine up until r3960 was checked in a few days ago.

Hi Matthew,

Looks like the new Date validation code I put in to get around some
SQLite problems isn't compatible with LazyDate. I'll try to have a
look at it tonight.

Apologies for the inconvenience.

Yours,
Russ Magee %-)

Reply all
Reply to author
Forward
0 new messages