I am trying to use BradWhittington Django-Templated-Email. I installed it, and added the following lines in the settings.py.
from templated_email.backends.vanilla_django import TemplateBackend
TEMPLATED_EMAIL_BACKEND = TemplateBackend
When I try to run the server, I get the import error. Even when I use
from templated_email import send_templated_mail
in the models.py I again get the import error. I am new to django, and I googled for the answer many times. But no luck. What am I missing? The 'Run' window on pycharm shows the following:
"C:\Program Files\JetBrains\PyCharm 4.0.4\bin\runnerw.exe" "E:\***\***\***\env1\Scripts\python.exe" "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py" syncdb "E:/***/***/***/***"
Traceback (most recent call last):
File "C:\Program Files\JetBrains\PyCharm 4.0.4\helpers\pycharm\django_manage.py", line 41, in <module>
run_module(manage_file, None, '__main__', True)
File "C:\Python34\Lib\runpy.py", line 182, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "C:\Python34\Lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Python34\Lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "E:/***/***/***/***\manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "E:\***\***\***\env1\lib\site-packages\django\core\management\__init__.py", line 345, in execute
settings.INSTALLED_APPS
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "E:\***\***\***\env1\lib\site-packages\django\conf\__init__.py", line 94, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "E:\***\***\***\env1\lib\importlib\__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "E:/***/***/***/***\***\settings.py", line 17, in <module>
from templated_email.backends.vanilla_django import TemplateBackend
File "E:\***\***\***\env1\lib\site-packages\templated_email\__init__.py", line 23
except ImportError, e:
^
SyntaxError: invalid syntax
Process finished with exit code 1
I am using virtual environment. Please help me.
Django-Templated-Email does not support python 3, which you are using.
You can migrate your project to python2, but it's better to find modern alternative to Django-Templated-Email.
Related
I ran into this problem and searched many resources but couldn't find a solution. My Django project was running successfully on my local. But when I deployed it to the server, it kept getting the following error.
ModuleNotFoundError: No module named 'proj'
I installed all the required libraries and all the settings should be correct as they worked fine on my OSX.
(venv) [root#10-10-7-140 vanilla]# python manage.py runserver
Traceback (most recent call last):
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 74, in execute
super().execute(*args, **options)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/base.py", line 460, in execute
output = self.handle(*args, **options)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 81, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 87, in __getattr__
self._setup(name)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 74, in _setup
self._wrapped = Settings(settings_module)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 183, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/python3.8/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'proj'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 446, in execute_from_command_line
utility.execute()
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/core/management/base.py", line 427, in run_from_argv
connections.close_all()
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/db/utils.py", line 212, in close_all
for alias in self:
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/utils/connection.py", line 73, in __iter__
return iter(self.settings)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/utils/functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/utils/connection.py", line 45, in settings
self._settings = self.configure_settings(self._settings)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/db/utils.py", line 148, in configure_settings
databases = super().configure_settings(databases)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/utils/connection.py", line 50, in configure_settings
settings = getattr(django_settings, self.settings_name)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 87, in __getattr__
self._setup(name)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 74, in _setup
self._wrapped = Settings(settings_module)
File "/data/www/vanilla/vanilla/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 183, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/python3.8/python3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'proj'
I noticed the message of if not settings.DEBUG and not settings.ALLOWED_HOSTS: and checked my code in venilla/settings.py, which includes:
DEBUG = True
ALLOWED_HOSTS = ['*']
Furthermore, the following line is standard in my manage.py.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'vanilla.settings')
I checked all the libraries are installed correctly, tried to run
python manage.py makemigrations and
python manage.py check. Got the same error.
Really wondering what caused my problem. Can anyone help? Thank you.
After checking the system, I found the following line in /etc/profile.
export DJANGO_SETTINGS_MODULE=proj.settings
It seta the DJANGO_SETTINGS_MODULE to proj.settings and cannot be overwritten by manage.py. After removing it and rebooting the system, the problem is resolved.
I am trying to run a Django project on my windows machine. I am getting nomodulefounderror. The project consists of multiple settings files for prod, Development, and Test.
I am using a virtual environment, Python 2.7 and Django 1.10 versions
I need help to run this project on my local machine.
Python manage.py runserver --settings=settings_dev_sai
It throws me an error. Here is my error log
python manage.py runserver --settings=bg.settings.settings_dev_sai
Traceback (most recent call last):
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 67, in handle
if not settings.DEBUG and not settings.ALLOWED_HOSTS:
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
self._setup(name)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "F:\brdge\bridge_sai\bridge\settings.py", line 38, in <module>
from settings_dev_sai import *
ModuleNotFoundError: No module named 'settings_dev_sai'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 341, in run_from_argv
connections.close_all()
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 225, in close_all
for alias in self:
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 219, in __iter__
return iter(self.databases)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\db\utils.py", line 153, in databases
self._databases = settings.DATABASES
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 76, in __getattr__
self._setup(name)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 63, in _setup
self._wrapped = Settings(settings_module)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\conf\__init__.py", line 142, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Users\1\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 961, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "F:\brdge\bridge_sai\bridge\settings.py", line 38, in <module>
from settings_dev_sai import *
ModuleNotFoundError: No module named 'settings_dev_sai'
manage.py File
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "bg.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Error log Updated
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "F:\brdge\env1\lib\site-packages\django\core\management\__init__.py", line 367, in execute_from_command_line
utility.execute()
File "F:\brdge\env1\lib\site-packages\django\core\management\__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 53, in __getattr__
self._setup(name)
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "F:\brdge\env1\lib\site-packages\django\conf\__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named settings_dev_sai
i think that you just need run it
python manage.py runserver --settings=bridge.settings_dev_sai
because bridge.settings is a file not a package
It seems your project dir name is 'bg', so I think while importing modules you should do
from bg import settings_dev_sai
or
from bg.settings_dev_sai import *
also make sure settings_dev_sai is in same dir 'bg'
I think i need to answer my question, The problem of nomodulefounderror, due to incomplete data in my Postgres database. I had dumped .sql file into the Postgres database which was given by my manager and later configured the settings file according to the database name and run command python manage.py runserver --settings=bg.settings_dev_sai. It worked perfectly.
I am running this code:
https://github.com/cndreisbach/call-for-service/blob/master/docs/src/development.md
When im running this part of code in my Vagrant shell :
python3 ./cfs/manage.py migrate --settings=cfs.settings.local
It's returning me that there is no "ImportError: No module named 'webapp_credentials'"
This is the error :
Traceback (most recent call last):
File "./cfs/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 351, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.5/dist-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 985, in _gcd_import
File "<frozen importlib._bootstrap>", line 968, in _find_and_load
File "<frozen importlib._bootstrap>", line 957, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 697, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/vagrant/cfs/cfs/settings/local.py", line 1, in <module>
from .base import *
File "/vagrant/cfs/cfs/settings/base.py", line 15, in <module>
from webapp_credentials import creds
ImportError: No module named 'webapp_credentials'
Is webapp_credentials a module of python OS how do i fix this?
webapp_credentials.py is on .gitignore, that is why migrate can't find it.
You need this file, which is not versioned in this git repository of your link.
I noticed that my Django-server crashes when I update pytz==2018.7 to pytz==2019.1. The Pytz library is in charge for all Timezone calculations. I ask myself if something changed and where I can find a changelog?
I did not change anything time related in my Django project and when I go back to pytz==2018.7 everything works fine.
I am using Django 2.2 with virtualenv, here is my list
Python==3.7.2
Django 2.2
Virtualenv==16.5.0
Django==2.2
django-widget-tweaks==1.4.3
djangorestframework==3.9.2
Pillow==6.0.0
Pygments==2.3.1
pytz==2018.7
sqlparse==0.3.0
Settings.py
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
<…>
latest crash with pytz==2019.1 update
(env2) D:\coding\Webprojects\phone>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\coding\virtual_env\env2\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "D:\coding\virtual_env\env2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\coding\appz\python 3_7_2_64bit\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "d:\coding\appz\python 3_7_2_64bit\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\contrib\admin\checks.py", line 80, in check_dependencies
for engine in engines.all():
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 90, in all
return [self[alias] for alias in self]
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "D:\coding\virtual_env\env2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\templatetags\rest_framework.py", line 15, in <module>
from rest_framework.renderers import HTMLFormRenderer
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\renderers.py", line 20, in <module>
from django.test.client import encode_multipart
File "D:\coding\virtual_env\env2\lib\site-packages\django\test\client.py", line 23, in <module>
from django.test import signals
File "<frozen importlib._bootstrap>", line 980, in _find_and_load
File "<frozen importlib._bootstrap>", line 149, in __enter__
File "<frozen importlib._bootstrap>", line 94, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 2019111034216
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\coding\Webprojects\phone\phone\urls.py", line 27, in <module>
path('data/', include('dataout.urls', namespace='data_home')),
File "D:\coding\virtual_env\env2\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "D:\coding\virtual_env\env2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\coding\Webprojects\phone\dataout\urls.py", line 2, in <module>
from rest_framework.urlpatterns import format_suffix_patterns
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\urlpatterns.py", line 8, in <module>
from rest_framework.settings import api_settings
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\settings.py", line 26, in <module>
from django.test.signals import setting_changed
File "D:\coding\virtual_env\env2\lib\site-packages\django\test\__init__.py", line 3, in <module>
from django.test.client import Client, RequestFactory
ImportError: cannot import name 'Client' from 'django.test.client' (D:\coding\virtual_env\env2\lib\site-packages\django\test\client.py)
I would like to enable my django-cms instance to host multiple sites.
For that I created two different sites in the admin panel.
Unfortunately only one site is shown because I needed to hardcode the SITE_ID in the project settings.
According to https://github.com/django/django/pull/2460 this is not a mandatory setting anymore. But my Django 1.10.7 instance shows the following traceback if I delete it:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/var/www/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
utility.execute()
File "/var/www/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 312, in execute
django.setup()
File "/var/www/venv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/var/www/venv/lib/python3.5/site-packages/django/apps/registry.py", line 115, in populate
app_config.ready()
File "/var/www/venv/lib/python3.5/site-packages/django/contrib/admin/apps.py", line 22, in ready
self.module.autodiscover()
File "/var/www/venv/lib/python3.5/site-packages/django/contrib/admin/__init__.py", line 24, in autodiscover
autodiscover_modules('admin', register_to=site)
File "/var/www/venv/lib/python3.5/site-packages/django/utils/module_loading.py", line 74, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/var/www/venv/lib/python3.5/site-packages/cms/admin/__init__.py", line 2, in <module>
import cms.admin.pageadmin
File "/var/www/venv/lib/python3.5/site-packages/cms/admin/pageadmin.py", line 39, in <module>
from cms.admin.forms import (
File "/var/www/venv/lib/python3.5/site-packages/cms/admin/forms.py", line 85, in <module>
class PageForm(forms.ModelForm):
File "/var/www/venv/lib/python3.5/site-packages/cms/admin/forms.py", line 86, in PageForm
language = forms.ChoiceField(label=_("Language"), choices=get_language_tuple(),
File "/var/www/venv/lib/python3.5/site-packages/cms/utils/i18n.py", line 76, in get_language_tuple
return [(lang['code'], lang['name']) for lang in get_languages(site_id)]
File "/var/www/venv/lib/python3.5/site-packages/cms/utils/i18n.py", line 23, in get_languages
site_id = get_site_id(site_id)
File "/var/www/venv/lib/python3.5/site-packages/cms/utils/conf.py", line 294, in get_site_id
return settings.SITE_ID
File "/var/www/venv/lib/python3.5/site-packages/django/conf/__init__.py", line 49, in __getattr__
return getattr(self._wrapped, name)
AttributeError: 'Settings' object has no attribute 'SITE_ID'
Looks like SITE_ID is required by Django CMS, it's in the traceback
File "/var/www/venv/lib/python3.5/site-packages/cms/utils/conf.py", line 294, in get_site_id
return settings.SITE_ID
I solved to problem differently.
I used the plugin djangocms-multisite.
I don't know if it is the best solution but it works.