Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#23998 closed Bug (fixed)

datetime.time default value on migrations

Reported by: Oscar Ramirez Owned by: Oscar Ramirez
Component: Migrations Version: 1.7
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When trying to use datetime.time(10) value for a django.db.models.fields.TimeField model default value on the default value questioner the system raises this exception:

The datetime module is available, so you can do e.g. datetime.date.today()
>>> datetime.time(10)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
  execute_from_command_line(sys.argv)
[....]
File "/Users/tuxskar/.virtualenvs/caluny/lib/python2.7/site-packages/django/db/migrations/questioner.py", line 126, in ask_not_null_addition
    return eval(code, {}, {"datetime": datetime_safe})
  File "<string>", line 1, in <module>
TypeError: 'module' object is not callable

I have made a patch and attach here. (Github Pull Request)

Change History (6)

comment:1 by Jayadeep Karnati, 10 years ago

Has patch: unset
Resolution: needsinfo
Status: newclosed

Can you provide the steps to reproduce the bug, more clearly? I don't get any error when I enter the following in the shell of django 1.7:

>>> import datetime
>>> datetime.time(10)

Is that what you meant?

Also, you have mentioned that a patch has been attached but I couldn't find any attachments.

comment:2 by Tim Graham, 10 years ago

Resolution: needsinfo
Status: closednew

The patch is linked in the "Pull Requests:" field on the ticket. The problem is with the migration questioner, not the plain Django shell.

comment:3 by Tim Graham, 10 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

comment:5 by Tim Graham <timograham@…>, 10 years ago

Resolution: fixed
Status: newclosed

In 54085b0f9ba7d9f705f9b9c90d3433b0ef6aa042:

Fixed #23998 -- Added datetime.time support to migrations questioner.

comment:6 by Tim Graham <timograham@…>, 10 years ago

In 1ad5deedd4c51729be680e3c2730c2ef5ab4f831:

[1.7.x] Fixed #23998 -- Added datetime.time support to migrations questioner.

Backport of 54085b0f9ba7d9f705f9b9c90d3433b0ef6aa042 from master

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