I'm setting up a simple db using Django and I got the above error when running 'python manage.py syncdb'
我正在使用Django设置一个简单的数据库,运行'python manage.py syncdb'时出现上述错误
Is this a problem in manage.py or my .db file? Suggestions for how to resolve?
这是manage.py或我的.db文件中的问题吗?建议如何解决?
EDIT: Adding full traceback
编辑:添加完整的追溯
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
app_name = get_commands()[subcommand]
File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
apps = settings.INSTALLED_APPS
File "/Library/Python/2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 776, in dictConfig
dictConfigClass(config).configure()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/logging/config.py", line 562, in configure
'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.CallbackFilter': No module named CallbackFilter
6 个解决方案
#1
6
Please double check if the django version 1.3.1 you have is the most recent one, because this is a bug in Django.
请仔细检查你的django 1.3.1版本是否是最新版本,因为这是Django中的一个错误。
To avoid such situations, I recommend to use virtualenv: How to create multiple Django environments using virtualenv
为了避免这种情况,我建议使用virtualenv:如何使用virtualenv创建多个Django环境
If you have the most recent version and still facing the issue, please update this bug: Ticket #16568 require_debug_false does not work as intended (backward incompatible)
如果您有最新版本但仍然面临问题,请更新此错误:票证#16568 require_debug_false无法正常工作(向后不兼容)
The bug also has a simple solution:
该bug还有一个简单的解决方案:
Remove require_debug_false from global_settings.py (since it does
not work) and force everyone to copy/paste the default LOGGING snippet to their settings
不起作用)并强制每个人将默认的LOGGING片段复制/粘贴到他们的设置中
Answer posted by django developer andreas_pelme here, this is not a bug and if correct version of django is installed, it should work fine.
由django developer andreas_pelme发布的答案,这不是一个bug,如果安装了正确版本的django,它应该可以正常工作。
~ $ mkvirtualenv t16568-regression
New python executable in t16568-regression/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/get_env_details
[t16568-regression] ~ $ pip install django==1.3.1
Downloading/unpacking django==1.3.1
Downloading Django-1.3.1.tar.gz (6.5Mb): 6.5Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
changing mode of /Users/andreas/.virtualenvs/t16568-regression/bin/django-admin.py to 755
Successfully installed django
Cleaning up...
[t16568-regression] ~ $ cd code/
[t16568-regression] ~ $ django-admin.py startproject foo
[t16568-regression] ~ $ cd foo/
[t16568-regression] ~/foo $ python manage.py shell
In [1]: import django; django.get_version()
Out[1]: '1.3.1'
#2
11
I had the same problem
我有同样的问题
Go to your settings.py and find the LOGGING settings
转到settings.py并找到LOGGING设置
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda r: not DEBUG
}
},
See the CallbackFilter there? Remove the whole 'filters' key. This happened because I tried to use the same settings.py file across 2 different Django versions. If you use djangoadmin.py startproject you get a valid settings.py file.
看那里的CallbackFilter?删除整个“过滤器”键。发生这种情况是因为我尝试在两个不同的Django版本中使用相同的settings.py文件。如果使用djangoadmin.py startproject,则会获得有效的settings.py文件。
#3
2
I have found the prolem. If we have worked with eclipse PyDev and create project into eclipse - we have incorrect project structure.
我找到了问题。如果我们使用eclipse PyDev并将项目创建到eclipse中 - 我们的项目结构不正确。
To solve this problem we need to create project in command line with manage.py startproject myprojectname and in eclipse create new Django project and specify older with already created project via command line tool.
要解决这个问题,我们需要在命令行中使用manage.py startproject myprojectname创建项目,并在eclipse中创建新的Django项目,并通过命令行工具指定已创建项目的旧项目。
Best regards, Anton.
最好的问候,安东。
#4
1
Have you tried re-installing django? If not, I think this is a great oportunity to start using virtual env.
你试过重新安装django吗?如果没有,我认为这是开始使用虚拟环境的一个很好的机会。
There is a class called CallbackFilter in
有一个名为CallbackFilter的类
/usr/local/lib/python2.6/dist-packages/django/utils/dictconfig.py
The fact that you can't read it, means either is not there or your python_path is not well configured, but since you can read other django stuff that is not probably the case.
您无法读取它的事实意味着要么不存在,要么您的python_path没有很好地配置,但是因为您可以阅读其他不太可能的django内容。
#5
1
I had the same problem, and in my case it was due to running manage.py using sudo, which ignores virtual env. There is a solution for this at this thread.
我有同样的问题,在我的情况下,这是由于使用sudo运行manage.py,忽略虚拟环境。在这个帖子中有一个解决方案。
#6
1
I had the same problem. I would say that the source of the problem is that your "setting.py" was created with a different Django version that your current version. If you dont know what version you have, I recommend you to start a new project in order to have a setting.py with your current Django version.
我有同样的问题。我会说问题的根源是你的“setting.py”是用你当前版本的不同Django版本创建的。如果你不知道你有什么版本,我建议你开始一个新项目,以便使用当前Django版本的setting.py。
If you know the Django version that you used to create the project, you can easily install it again with the next command ( example Django version 1.4.5)
如果您知道用于创建项目的Django版本,则可以使用下一个命令轻松安装它(例如Django 1.4.5版)
pip install Django==1.4.5
I hope this can help.
我希望这可以提供帮助。
#1
6
Please double check if the django version 1.3.1 you have is the most recent one, because this is a bug in Django.
请仔细检查你的django 1.3.1版本是否是最新版本,因为这是Django中的一个错误。
To avoid such situations, I recommend to use virtualenv: How to create multiple Django environments using virtualenv
为了避免这种情况,我建议使用virtualenv:如何使用virtualenv创建多个Django环境
If you have the most recent version and still facing the issue, please update this bug: Ticket #16568 require_debug_false does not work as intended (backward incompatible)
如果您有最新版本但仍然面临问题,请更新此错误:票证#16568 require_debug_false无法正常工作(向后不兼容)
The bug also has a simple solution:
该bug还有一个简单的解决方案:
Remove require_debug_false from global_settings.py (since it does
not work) and force everyone to copy/paste the default LOGGING snippet to their settings
不起作用)并强制每个人将默认的LOGGING片段复制/粘贴到他们的设置中
Answer posted by django developer andreas_pelme here, this is not a bug and if correct version of django is installed, it should work fine.
由django developer andreas_pelme发布的答案,这不是一个bug,如果安装了正确版本的django,它应该可以正常工作。
~ $ mkvirtualenv t16568-regression
New python executable in t16568-regression/bin/python
Installing setuptools............done.
Installing pip...............done.
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/predeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postdeactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/preactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/postactivate
virtualenvwrapper.user_scripts creating /Users/andreas/.virtualenvs/t16568-regression/bin/get_env_details
[t16568-regression] ~ $ pip install django==1.3.1
Downloading/unpacking django==1.3.1
Downloading Django-1.3.1.tar.gz (6.5Mb): 6.5Mb downloaded
Running setup.py egg_info for package django
Installing collected packages: django
Running setup.py install for django
changing mode of build/scripts-2.7/django-admin.py from 644 to 755
changing mode of /Users/andreas/.virtualenvs/t16568-regression/bin/django-admin.py to 755
Successfully installed django
Cleaning up...
[t16568-regression] ~ $ cd code/
[t16568-regression] ~ $ django-admin.py startproject foo
[t16568-regression] ~ $ cd foo/
[t16568-regression] ~/foo $ python manage.py shell
In [1]: import django; django.get_version()
Out[1]: '1.3.1'
#2
11
I had the same problem
我有同样的问题
Go to your settings.py and find the LOGGING settings
转到settings.py并找到LOGGING设置
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.CallbackFilter',
'callback': lambda r: not DEBUG
}
},
See the CallbackFilter there? Remove the whole 'filters' key. This happened because I tried to use the same settings.py file across 2 different Django versions. If you use djangoadmin.py startproject you get a valid settings.py file.
看那里的CallbackFilter?删除整个“过滤器”键。发生这种情况是因为我尝试在两个不同的Django版本中使用相同的settings.py文件。如果使用djangoadmin.py startproject,则会获得有效的settings.py文件。
#3
2
I have found the prolem. If we have worked with eclipse PyDev and create project into eclipse - we have incorrect project structure.
我找到了问题。如果我们使用eclipse PyDev并将项目创建到eclipse中 - 我们的项目结构不正确。
To solve this problem we need to create project in command line with manage.py startproject myprojectname and in eclipse create new Django project and specify older with already created project via command line tool.
要解决这个问题,我们需要在命令行中使用manage.py startproject myprojectname创建项目,并在eclipse中创建新的Django项目,并通过命令行工具指定已创建项目的旧项目。
Best regards, Anton.
最好的问候,安东。
#4
1
Have you tried re-installing django? If not, I think this is a great oportunity to start using virtual env.
你试过重新安装django吗?如果没有,我认为这是开始使用虚拟环境的一个很好的机会。
There is a class called CallbackFilter in
有一个名为CallbackFilter的类
/usr/local/lib/python2.6/dist-packages/django/utils/dictconfig.py
The fact that you can't read it, means either is not there or your python_path is not well configured, but since you can read other django stuff that is not probably the case.
您无法读取它的事实意味着要么不存在,要么您的python_path没有很好地配置,但是因为您可以阅读其他不太可能的django内容。
#5
1
I had the same problem, and in my case it was due to running manage.py using sudo, which ignores virtual env. There is a solution for this at this thread.
我有同样的问题,在我的情况下,这是由于使用sudo运行manage.py,忽略虚拟环境。在这个帖子中有一个解决方案。
#6
1
I had the same problem. I would say that the source of the problem is that your "setting.py" was created with a different Django version that your current version. If you dont know what version you have, I recommend you to start a new project in order to have a setting.py with your current Django version.
我有同样的问题。我会说问题的根源是你的“setting.py”是用你当前版本的不同Django版本创建的。如果你不知道你有什么版本,我建议你开始一个新项目,以便使用当前Django版本的setting.py。
If you know the Django version that you used to create the project, you can easily install it again with the next command ( example Django version 1.4.5)
如果您知道用于创建项目的Django版本,则可以使用下一个命令轻松安装它(例如Django 1.4.5版)
pip install Django==1.4.5
I hope this can help.
我希望这可以提供帮助。