Opened 19 years ago

Closed 18 years ago

Last modified 18 years ago

#1451 closed defect (fixed)

[magic-removal] AttributeError when editing User in admin

Reported by: James Bennett Owned by: Adrian Holovaty
Component: Database layer (models, ORM) Version:
Severity: major Keywords:
Cc: malcolm@… Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When editing a user in the admin, as of rev 2475, we get an AttributeError:

{{{ Traceback (most recent call last):
File "/Users/james/dev/magic-removal/magic-removal/django/core/handlers/base.py" in get_response

  1. response = callback(request, *callback_args, callback_kwargs)

File "/Users/james/dev/magic-removal/magic-removal/django/contrib/admin/views/decorators.py" in _checklogin

  1. return view_func(request, *args, kwargs)

File "/Users/james/dev/magic-removal/magic-removal/django/contrib/admin/views/main.py" in change_stage

  1. new_data = manipulator.flatten_data()

File "/Users/james/dev/magic-removal/magic-removal/django/db/models/manipulators.py" in flatten_data

  1. new_data.update(f.flatten_data(fol, obj))

File "/Users/james/dev/magic-removal/magic-removal/django/db/models/fields/init.py" in flatten_data

  1. return {date_field: (val is not None and val.strftime("%Y-%m-%d") or ),

AttributeError at /admin/auth/user/1/
'str' object has no attribute 'strftime'} }}}

Change History (6)

comment:1 by James Bennett, 19 years ago

OK, so atm Trac's wikiformatting isn't doing code, and it interpreted the line numbers as beginning ordered lists. Line numbers, in order, should be: 73, 54, 352, 247, 413.

comment:2 by jkocherhans, 19 years ago

This should be the correct traceback:

Traceback (most recent call last):
File "/Users/james/dev/magic-removal/magic-removal/django/core/handlers/base.py" in get_response
  73. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/james/dev/magic-removal/magic-removal/django/contrib/admin/views/decorators.py" in _checklogin
  54. return view_func(request, *args, **kwargs)
File "/Users/james/dev/magic-removal/magic-removal/django/contrib/admin/views/main.py" in change_stage
  352. new_data = manipulator.flatten_data()
File "/Users/james/dev/magic-removal/magic-removal/django/db/models/manipulators.py" in flatten_data
  247. new_data.update(f.flatten_data(fol, obj))
File "/Users/james/dev/magic-removal/magic-removal/django/db/models/fields/__init__.py" in flatten_data
  413. return {date_field: (val is not None and val.strftime("%Y-%m-%d") or ''),

  AttributeError at /admin/auth/user/1/
  'str' object has no attribute 'strftime'} 

comment:3 by matt, 19 years ago

For those of you playing along at home, this seems to not be an issue for me on OSX10.4/Python 2.4.1/sqlite 3.1.3/pysqlite 2.0.7. The only difference between our two setups is that James is using Python 2.3.5.

Very weird.

comment:4 by James Bennett, 19 years ago

Component: Admin interfaceDatabase wrapper

We've found a clue: on Matt's setup (Python 2.4.1), nothing goes wrong. On my setup (Python 2.3.5), the typecast functions in django.db.backends.util aren't coming into play; specifically, typecast_timestamp is never getting called on this datetime string.

comment:5 by Malcolm Tredinnick <malcolm@…>, 19 years ago

Cc: malcolm@… added

So something is not quite right in this report. In revision 2475, the last line of the traceback would have occurred on line 422, not 413. So is you entire codebase up to date here? I am asking because I cannot repeat this problem at all with Python 2.3.4, SQlite 3.2.7 and pysqlite 2.0.4 (on linux-x86).

Does any editing of the User cause this problem, or is there a specific change that needs to be made to trigger it?

comment:6 by Adrian Holovaty, 18 years ago

Resolution: fixed
Status: newclosed

Please reopen if this is still a problem.

Note: See TracTickets for help on using tickets.
Back to Top