开发者

ValueError: Unable to configure filter 'require_debug_false': Cannot resolve 'django.utils.log.CallbackFilter': No module named CallbackFilter

I'm setting up a simple db using Django and I got the above error when running 'python manage.py syncdb'

Is this a problem in manage.py or my .db file? Suggestions for how to resolve?

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


I had the same problem

Go to your settings.py and find the LOGGING settings

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.


Please double check if the django version 1.3.1 you have is the most recent one, because this is a bug in Django.

To avoid such situations, I recommend to use virtualenv: How to create multiple Django environments using virtualenv

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)

The bug also has a simple solution:

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

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.

~ $ 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'


I have found the prolem. If we have worked with eclipse PyDev and create project into eclipse - we have incorrect project structure.

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.

Best regards, Anton.


Have you tried re-installing django? If not, I think this is a great oportunity to start using virtual env.

There is a class called CallbackFilter in

/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.


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.


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.

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)

pip install Django==1.4.5

I hope this can help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜