Re: Django-jython problem when rendering admin user detail template

Jim Baker <[email protected]>
Newsgroups gmane.comp.lang.jython.user
Message-ID <CAOhO=aO_Jete54G8QRQ74G3BDrkxiN=oy3tbhDF4295qWjrckA@mail.gmail.com>
I think this can be readily explained:

1) sqlite3 lacks explicit datetime support (
https://www.sqlite.org/datatype3.html), as 'bobince' points out in the
StackOverflow discussion (
http://stackoverflow.com/questions/33637913/django-unicode-issue-with-datetime-in-jython-with-sqlite-jdbc#comment55077398_33637913
)
2) django.db.backends.sqlite3 works around this via storing as text in
ISO-8601 format
3) but this is not part of JDBC support, which expects real datetime support

Note there is an outstanding bug to add complete sqlite3 support to Jython (
http://bugs.jython.org/issue1682864). I just adjusted the milestone for
that bug to 2.7.2 (could be later). Such support is something we have
wanted to do for a while, although it's a bit complicated because it's not
just a question of using JDBC.

For the time being, this likely means you would to either do your own
workaround (don't know scope); or switch to a database like MySQL or Apache
Derby (small footprint like sqlite3, but with support for datetimes).

- Jim

On Wed, Nov 11, 2015 at 11:52 AM, Diego Muñoz <[email protected]> wrote:

> I made this question in StackOverflow to get answers and comments:
>
>
> http://stackoverflow.com/questions/33637913/django-unicode-issue-with-datetime-in-jython-with-sqlite-jdbc
>
> It seems there is a bug when reading the info provided by the JDBC from
> django. The format that django gets is not the correct, as you can see in
> the screenshot I attached in the question.
>
> 2015-11-10 16:00 GMT-03:00 Diego Muñoz <[email protected]>:
>
>> I'd like to add some extra information:
>>
>> I am using the sqlite-jdbc-3.8.11.2.jar file, and I tried to dump data
>> from auth.User with "jython manage.py dumpdata auth.User --indent=4
>> --traceback" and I got this error:
>>
>> [Traceback (most recent call last):
>>   File "manage.py", line 10, in <module>
>>     execute_from_command_line(sys.argv)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/management/__init__.py",
>> line 354, in execute_from_command_line
>>     utility.execute()
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/management/__init__.py",
>> line 346, in execute
>>     self.fetch_command(subcommand).run_from_argv(self.argv)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/management/base.py", line
>> 394, in run_from_argv
>>     self.execute(*args, **cmd_options)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/management/base.py", line
>> 445, in execute
>>     output = self.handle(*args, **options)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/management/commands/dumpdata.py",
>> line 159, in handle
>>     serializers.serialize(format, get_objects(), indent=indent,
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/serializers/__init__.py",
>> line 129, in serialize
>>     s.serialize(queryset, **options)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/serializers/base.py",
>> line 61, in serialize
>>     self.handle_field(obj, field)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/core/serializers/python.py",
>> line 55, in handle_field
>>     self._current[field.name] = field.value_to_string(obj)
>>   File
>> "/home/dmunoz/jsnmp/Lib/site-packages/django/db/models/fields/__init__.py",
>> line 1487, in value_to_string
>>     return '' if val is None else val.isoformat()
>> AttributeError: 'unicode' object has no attribute 'isoformat'
>>
>> 2015-11-10 12:34 GMT-03:00 Diego Muñoz <[email protected]>:
>>
>>> Hi everyone,
>>>
>>> I recently created a Django 1.8.6 project in Jython, and installed
>>> django-jython 1.8.0b3. I am successfully using the SQLite JDBC and created
>>> a database in which I created a super user with "jython manage.py
>>> createsuperuser".
>>>
>>> In the localhost:8000/admin/ page I can successfully login and create
>>> users, but when I try to edit details about a User, I get an error:
>>> 'unicode' object has no attribute 'tzinfo'. If I change my settings.py file
>>> with USE_TZ = False, I get another error: 'unicode' object has no attribute
>>> 'date'.
>>>
>>> I would greatly appreciate any help. The exception I get for each case
>>> is:
>>>
>>> *1. 'unicode' object has no attribute 'tzinfo':*
>>>
>>> AttributeError at /admin/auth/user/1/
>>>
>>> 'unicode' object has no attribute 'tzinfo'
>>>
>>> Request Method: GET
>>> Request URL: http://localhost:8000/admin/auth/user/1/
>>> Django Version: 1.8.6
>>> Exception Type: AttributeError
>>> Exception Value:
>>>
>>> 'unicode' object has no attribute 'tzinfo'
>>>
>>> Exception Location:
>>> /home/dmunoz/jsnmp/Lib/site-packages/django/utils/timezone.py in is_aware,
>>> line 337
>>> Python Executable: /home/dmunoz/jsnmp/bin/jython
>>> Python Version: 2.7.0
>>> Python Path:
>>>
>>> ['/home/dmunoz/snmp/webswitcher',
>>>  '/home/dmunoz/jsnmp/Lib/site-packages/django_jython-1.8.0b3-py2.7.egg',
>>>  '/home/dmunoz/jsnmp/Lib/site-packages',
>>>  '/home/dmunoz/jsnmp/Lib',
>>>  '/home/dmunoz/opt/jython2.7.0/Lib',
>>>  '__classpath__',
>>>  '__pyclasspath__/']
>>>
>>> Server time: Tue, 10 Nov 2015 12:31:09 -0300
>>>
>>> Error during template rendering
>>>
>>> In template
>>> /home/dmunoz/jsnmp/Lib/site-packages/django/contrib/admin/templates/admin/includes/fieldset.html,
>>> error at line 19
>>>
>>> *2. 'unicode' object has no attribute 'date':*
>>>
>>> AttributeError at /admin/auth/user/1/
>>>
>>> 'unicode' object has no attribute 'date'
>>>
>>> Request Method: GET
>>> Request URL: http://localhost:8000/admin/auth/user/1/
>>> Django Version: 1.8.6
>>> Exception Type: AttributeError
>>> Exception Value:
>>>
>>> 'unicode' object has no attribute 'date'
>>>
>>> Exception Location:
>>> /home/dmunoz/jsnmp/Lib/site-packages/django/forms/widgets.py in decompress,
>>> line 888
>>> Python Executable: /home/dmunoz/jsnmp/bin/jython
>>> Python Version: 2.7.0
>>> Python Path:
>>>
>>> ['/home/dmunoz/snmp/webswitcher',
>>>  '/home/dmunoz/jsnmp/Lib/site-packages/django_jython-1.8.0b3-py2.7.egg',
>>>  '/home/dmunoz/jsnmp/Lib/site-packages',
>>>  '/home/dmunoz/jsnmp/Lib',
>>>  '/home/dmunoz/opt/jython2.7.0/Lib',
>>>  '__classpath__',
>>>  '__pyclasspath__/']
>>>
>>> Server time: Tue, 10 Nov 2015 12:28:18 -0300
>>>
>>> Error during template rendering
>>>
>>> In template
>>> /home/dmunoz/jsnmp/Lib/site-packages/django/contrib/admin/templates/admin/includes/fieldset.html,
>>> error at line 19
>>>
>>> Regards,
>>> Diego
>>>
>>>
>>>
>>
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Jython-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jython-users
>
>

------------------------------------------------------------------------------

_______________________________________________
Jython-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jython-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.