Fixed it.

I was assigning a string to a date field.  Django is ok with this, django-
reversion isn't.

Changed:

lDate = '%s-%s-%s' % (lYear, lMonth, lDay)
lContestEvent.date_of_event = lDate

to:

lContestEvent.date_of_event = date(int(lYear), int(lMonth), int(lDay))

and all appears fine.

Tim.

On Tuesday 02 June 2009 22:01:26 Tim Sawyer wrote:
> Hi,
>
> I'm using django svn 10784, and I've just added django-reversion, latest
> svn version from trunk (198).  I'm using the middleware option for django-
> reversion.
>
> It's not working, and I'm getting the following error.  I've tried with the
> same django version and the tagged 1.1.1 release of django-reversion, but I
> get the same problem.
>
> The error occurs on a save and is:
>
>
> Traceback (most recent call last):
>
>   File "/home/mybandsite/django-trunk/django/core/servers/basehttp.py",
> line 278, in run
>     self.result = application(self.environ, self.start_response)
>
>   File "/home/mybandsite/django-trunk/django/core/servers/basehttp.py",
> line 636, in __call__
>     return self.application(environ, start_response)
>
>   File "/home/mybandsite/django-trunk/django/core/handlers/wsgi.py", line
> 245, in __call__
>     response = middleware_method(request, response)
>
>   File "/home/mybandsite/src/reversion/middleware.py", line 23, in
> process_response
>     reversion.revision.end()
>
>   File "/home/mybandsite/src/reversion/revisions.py", line 263, in end
>     serialized_data = serializers.serialize(registration_info.format,
> [obj], fields=registration_info.fields)
>
>   File "/home/mybandsite/django-trunk/django/core/serializers/__init__.py",
> line 87, in serialize
>     s.serialize(queryset, **options)
>
>   File "/home/mybandsite/django-trunk/django/core/serializers/base.py",
> line 44, in serialize
>     self.handle_field(obj, field)
>
>   File "/home/mybandsite/django-
> trunk/django/core/serializers/xml_serializer.py", line 70, in handle_field
>     self.xml.characters(field.value_to_string(obj))
>
>   File "/home/mybandsite/django-trunk/django/db/models/fields/__init__.py",
> line 518, in value_to_string
>     data = datetime_safe.new_date(val).strftime("%Y-%m-%d")
>
>   File "/home/mybandsite/django-trunk/django/utils/datetime_safe.py", line
> 30, in new_date
>     return date(d.year, d.month, d.day)
>
> AttributeError: 'unicode' object has no attribute 'year'
>
> I think this might be something to do with my MIDDLEWARE_CLASSES which is
> set to:
>
> MIDDLEWARE_CLASSES = (
>     'django.contrib.sessions.middleware.SessionMiddleware',
>     'django.contrib.auth.middleware.AuthenticationMiddleware',
>     'django.middleware.transaction.TransactionMiddleware',
>     'reversion.middleware.RevisionMiddleware',
>     'django.middleware.common.CommonMiddleware',
>     'django.middleware.doc.XViewMiddleware',
> )
>
> which doesn't match the recommendation from the django-reversion site.  I
> had to put the AuthenticationMiddleware first so that request.user was
> available for the RevisionMiddleware to use, and that dragged the
> SessionMiddleware in too.
>
> Any clues anyone?
>
> Thanks,
>
> Tim.
>
> 

--~--~---------~--~----~------------~-------~--~----~
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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to