{{{
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 353, in
execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python2.7/dist-
packages/raven/contrib/django/management/__init__.py", line 41, in
new_execute
return original_func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/base.py", line 399, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/migrate.py", line 89, in handle
executor = MigrationExecutor(connection,
self.migration_progress_callback)
File "/usr/local/lib/python2.7/dist-
packages/django/db/migrations/executor.py", line 20, in __init__
self.loader = MigrationLoader(self.connection)
File "/usr/local/lib/python2.7/dist-
packages/django/db/migrations/loader.py", line 49, in __init__
self.build_graph()
File "/usr/local/lib/python2.7/dist-
packages/django/db/migrations/loader.py", line 170, in build_graph
self.load_disk()
File "/usr/local/lib/python2.7/dist-
packages/django/db/migrations/loader.py", line 105, in load_disk
migration_module = import_module("%s.%s" % (module_name,
migration_name))
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in
import_module
__import__(name)
File "/root/filmow/src/filmow/quizzes/migrations/0001_initial.py", line
12, in <module>
class Migration(migrations.Migration):
File "/root/filmow/src/filmow/quizzes/migrations/0001_initial.py", line
63, in Migration
('end_date', models.DateTimeField(default=datetime(2016, 7, 4, 15, 18,
59, 481979))),
TypeError: 'module' object is not callable
}}}
I tested with 1.9.5 and 1.9.3 versions
--
Ticket URL: <https://code.djangoproject.com/ticket/26839>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0
Comment:
Please provide the content of the `quizzes/migrations/0001_initial.py`
file.
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:1>
Comment (by henriquechehad):
The migration line with issue is it:
{{{
('end_date', models.DateTimeField(default=datetime(2016, 7, 4, 15, 18, 59,
481979))),
}}}
Import:
{{{
# -*- coding: utf-8 -*-
# Generated by Django 1.9.5 on 2016-07-04 15:19
from __future__ import unicode_literals
import datetime
}}}
I changed "import datetime" to "from datetime import datetime" and fixed
the issue.
But I don't know why Django generated migration file using datetime
instead datetime.datetime.
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:2>
Comment (by charettes):
What's you model's `end_date` default? I tried reproducing with
`datetime.datetime.now()` and `datetime(2016, 7, 4, 15, 18, 59, 481979)`
and in both cases the appropriate object (`datetime.datetime`) was
imported correctly in the generated migration.
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:3>
Comment (by henriquechehad):
Thank you. Located the problem. Is local.
The default option calls another code that have the bellow code:
{{{
try:
from django.utils.timezone import utc, now, today
except ImportError:
return datetime.now()
}}}
Django 1.9 doesn't have the path "django.utils.timezone.now"
The ImportError returns the wrong value!
Thank you!
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:4>
* resolution: needsinfo => fixed
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:5>
* resolution: fixed => invalid
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:6>
Comment (by cronywalls):
This error statement [http://net-informations.com/python/iq/typeerror.htm
TypeError]: 'module' object is not callable is raised as you are being
confused about the Class name and Module name. The problem is in the
import line . You are importing a module, not a class. This happend
because the module name and class name have the same name .
If you have a class "MyClass" in a file called "MyClass.py" , then you
should import :
{{{
from MyClass import MyClass
}}}
In Python , a script is a module, whose name is determined by the filename
. So when you start out your file MyClass.py with import MyClass you are
creating a loop in the module structure.
In Python, everything (including functions, methods, modules, classes
etc.) is an object , and methods are just attributes like every others.
So,there's no separate namespaces for methods. So when you set an instance
attribute, it shadows the class attribute by the same name. The obvious
solution is to give attributes different names.
--
Ticket URL: <https://code.djangoproject.com/ticket/26839#comment:7>