ImportError: cannot import name signals

匆匆过客 提交于 2019-12-05 05:40:02

@Hugo was right in that it was a settings.py problem. But I didn't had that problem when running through the Django environment. But when I wanted to run unit tests one by one (By using Pydev's run as unittest) it failed to run. What I needed to do was to add the Django settings module information, so for now what I'm doing is adding the following lines to my unit tests:

from django.core import management;
import BookIt.settings as settings;
management.setup_environ(settings)

This loads my Django project settings and allow me to run as regular unittest. If anyone has better suggestion on how to configure this more cleanly in Pydev please let me know.

I had the same problem just a minute ago. Investigating I realized the problem was with my settings.py* file.

Check if you are having problems with Django finding your settings file correctly.

This error message is totally non-sense.

* IIRC Django looks for settings.py file, if not found, it looks for environment variable DJANGO_SETTINGS_MODULE and try that.

This is easy to solve. If you have already written the settings.py (most probable) just navigate into the directory which contains the "settings.py" file and execute it.

1] python 2] import settings

These commands should do the trick. Then go to any folder and continue with execution.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!