Code

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#1451 closed defect (fixed)

[magic-removal] AttributeError when editing User in admin

Reported by: ubernostrum Owned by: adrian
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: UI/UX:

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'} }}}

Attachments (0)

Change History (6)

comment:1 Changed 8 years ago by ubernostrum

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 Changed 8 years ago by jkocherhans

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 Changed 8 years ago by matt

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 Changed 8 years ago by ubernostrum

  • Component changed from Admin interface to Database 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 Changed 8 years ago by Malcolm Tredinnick <malcolm@…>

  • 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 Changed 8 years ago by adrian

  • Resolution set to fixed
  • Status changed from new to closed

Please reopen if this is still a problem.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.