rfostii / wadofstuff

Automatically exported from code.google.com/p/wadofstuff
0 stars 0 forks source link

Failure serialising reused Django DateTimeField in 1.1.0 #15

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Take a simple Django 1.2 or 1.3 model with a DateTimeField.

lastScanned = models.DateTimeField( blank=True, null=True )

2. Change the value of the field to a different type of data:

obj.lastScanned = timesince( obj.lastScanned )
# Hey, it's now a string

3. Try to serialise the object.

serializers.serialize( "json", [ device, ] )

What is the expected output? What do you see instead?

I expect to see the object serialised nicely -- and this does happen in 
wadofstuff 1.0.0. However, in 1.1.0 it is broken and I get a parse error from 
Django.

/usr/local/lib/python2.6/dist-packages/django/utils/datetime_safe.py:36 throws 
"'unicode' object has no attribute 'year'", but 
wadofstuff_django_serializers-1.1.0-py2.6.egg/wadofstuff/django/serializers/pyth
on.py:71 seems to be the critical bit.

What version of the product are you using? On what operating system?

1.1.0 from easy_install.

Please provide any additional information below.

Some caveats with this one:

 - Yes, this is stupid thing I was trying to do, but re-using fields saves me putting new ones through the serialiser as "extras"
 - The exception is raised by Django: but it's the difference between 1.0.0 and 1.1.0 of wadofstuff which "breaks" Django

Thanks.

Original issue reported on code.google.com by ai...@reincubate.com on 24 Apr 2011 at 9:51