Re: error psycopg in Django/MacOSX

Daniele Varrazzo <[email protected]> Tue, 3 Aug 2010 16:49:12 +0100
Newsgroups gmane.comp.python.db.psycopg.devel
Message-ID <[email protected]>
2010/8/3 Daniel Fran=E7a <[email protected]>:
> Hi Daniele, I'm not at home right now(where the error happens), but
> I'll try to explain.
> I'm using psycopg2 w/ django.
> in django there's a timezone env. variable that I set in a settings file.
> something like this:
> TIMEZONE=3D"US/Eastern"
>
> the problem is, whatever I put there I get a message error like this:
> "Can't adapt type 'US/Eastern'"
> if I change to TIMEZONE=3D"America/Sao_Paulo" I get: "Can't adapt type
> 'America/Sao_Paulo'"
> it was working fine this way in GNU/Linux, but now in Mac OSX I got
> this error. Perhaps =A0it's something internal to django framework?

Yes, looks like every timezone in django is a type on its own. Maybe
on Linux you tested with a previous version where the timezones were
just strings. If this is the case, maybe passing
str(settings.TIMEZONE) will work.

I've django 1.2 installed anyway and here:

 - the setting I have is called TIME_ZONE, not TIMEZONE
 - this setting is a string.

Are you testing with django trunk? Can you report what the setting
really is from an interactive shell?

    python /path/to/project/manage.py shell
    >>> from django.conf import settings
    >>> settings.TIME_ZONE
    'London/Europe'
    >>> type(settings.TIME_ZONE)
    <type 'str'>
    >>> import django
    >>> print django.VERSION
    (1, 2, 0, 'final', 0)

Just to check we are talking about the same thing...

-- Daniele