django can't find tinymce - python

I am using django 4.0.2 and django-tinymce 3.4.0 python 3.8
I am trying use tinymce as text editor by adding this line to main/urls.py
urlpatterns = [
...,
path(r'^tinymce/', include('tinymce.urls')),
....,
]
but is says no module named tinymce
i also tried import tinymce
installed after activating in virtual env using pip install django-tinymce.
enter codxception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/core/management/base.py", line 438, in check
all_issues = checks.run_checks(
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/core/checks/registry.py", line 77, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/urls/resolvers.py", line 448, in check
for pattern in self.url_patterns:
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/urls/resolvers.py", line 634, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/urls/resolvers.py", line 627, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/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 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/ubuntu/Desktop/guftaho/guftaho/urls.py", line 23, in <module>
path(r'^tinymce/', include('tinymce.urls')),
File "/home/ubuntu/Desktop/guftaho/genv/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'tinymce.urls'
any sugesstions, please?

Several files are missing from the pip install. Go to the GitHub repository and download the files manually from the tinymce directory. You can copy that to your site-packages directory in your virtual environment.
I just opened an issue about this myself.
https://github.com/jazzband/django-tinymce/issues/400

Related

Django-error OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2

When I do manage.py makemigrations
An error like this occurs
PS C:\Users\User\PycharmProject\onlineshop-master> python .\manage.py makemigrations
Traceback (most recent call last):
File "C:\Users\User\PycharmProject\onlineshop-master\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\base.py", line 350, in execute
self.check()
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\base.py", line 376, in check
all_issues = self._run_checks(
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\User\PycharmProject\onlineshop-master\config\urls.py", line 24, in <module>
path('order/', include('order.urls')),
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\User\PycharmProject\onlineshop-master\order\urls.py", line 2, in <module>
from .views import *
File "C:\Users\User\PycharmProject\onlineshop-master\order\views.py", line 36, in <module>
import weasyprint
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\weasyprint\__init__.py", line 393, in <module>
from .css import preprocess_stylesheet # noqa
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\weasyprint\css\__init__.py", line 25, in <module>
from . import computed_values
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\weasyprint\css\computed_values.py", line 17, in <module>
from .. import text
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\weasyprint\text.py", line 14, in <module>
import cairocffi as cairo
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\cairocffi\__init__.py", line 41, in <module>
cairo = dlopen(ffi, 'cairo', 'cairo-2', 'cairo-gobject-2')
File "C:\Users\User\PycharmProject\onlineshop\venv\lib\site-packages\cairocffi\__init__.py", line 38, in dlopen
raise OSError("dlopen() failed to load a library: %s" % ' / '.join(names))
OSError: dlopen() failed to load a library: cairo / cairo-2 / cairo-gobject-2
I can't figure out a workaround.
How can I solve this?
'''
pip install cffi
'''
Requirement already satisfied: cffi in c:\users\user\pycharmproject\onlineshop\venv\lib\site-packages (1.15.0)
Requirement already satisfied: pycparser in c:\users\user\pycharmproject\onlineshop\venv\lib\site-packages (from cffi) (2.19)
check the cairocffi package has an issue or not and even it is correctly installed or not. And try to install it again, so maybe these issues will be solved.
Also check your database. like when you write python manage.py make migrations , if your database is not created as superuser, so it will give you errors
if your packages are already satisfied then try to uninstall it

Django make migrations returns ModuleNotFoundError

I'm just starting to learn Django through online lectures and I'm trying to run this command
python3 manage.py makemigrations
It returns the following error
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 "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/base.py", line 368, in execute
self.check()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/management/base.py", line 392, in check
all_issues = checks.run_checks(
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/checks/registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/urls/resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/urls/resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/3.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 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 "/Users/dan/Documents/College/CS50 Web Programming/week 4/airline/airline/urls.py", line 21, in <module>
path("flights/", include("flights.url"))
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/3.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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'flights.url'
I've checked to make sure Python and Django are up to date, and that I have the correct app installed in INSTALLED_APPS
I supposse you misspelled the urls.py file in yourproject/urls.py
path('flights/', include('flights.urls'))

Why am I getting ImportError on render_to_response method if it's not included anywhere?

I'm working on a Django project, and when I want to run it locally, I get the following:
ImportError: cannot import name 'render_to_response' from 'django.shortcuts'
However, I'm not including render_to_response method anywhere in the project, as I checked. I believe it's probably something like an incompatibility issue between any library, although I can't tell.
My python version is 3.7, my Django version is 3.1, my pip version is 20.2.2.
My pip freeze returns this:
allauth-django==0.42.6
asgiref==3.2.10
certifi==2020.6.20
chardet==3.0.4
defusedxml==0.6.0
Django==3.1
django-crispy-forms==1.9.2
django-filter==2.3.0
django-tables2==2.3.1
idna==2.10
mysqlclient==2.0.1
oauthlib==3.1.0
python3-openid==3.2.0
pytz==2020.1
requests==2.24.0
requests-oauthlib==1.3.0
sqlparse==0.3.1
tablib==2.0.0
urllib3==1.25.10
Any help would be appreciated.
The full stack trace is this:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\IvanH\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\IvanH\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\core\management\base.py", line 396, in check
databases=databases,
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\urls\resolvers.py", line 408, in check
for pattern in self.url_patterns:
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\IvanH\AppData\Local\Programs\Python\Python37\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 "C:\Users\IvanH\PycharmProjects\sare_project\SareProject\urls.py", line 25, in <module>
path('formats/', include('formats.urls')),
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\IvanH\AppData\Local\Programs\Python\Python37\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 "C:\Users\IvanH\PycharmProjects\sare_project\formats\urls.py", line 25, in <module>
path('accounts/', include('allauth.urls')),
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\IvanH\AppData\Local\Programs\Python\Python37\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 "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\allauth\urls.py", line 5, in <module>
from allauth.django_utils.admin import *
File "C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\allauth\django_utils\admin.py", line 5, in <module>
from django.shortcuts import render_to_response
ImportError: cannot import name 'render_to_response' from 'django.shortcuts' (C:\Users\IvanH\PycharmProjects\sare_project\venv\lib\site-packages\django\shortcuts.py)
UPDATE
When I try to uninstall it, and install allauth-django 0.42.0, with the command pip install allauth-django==0.42.0, I get the following error:
ERROR: Could not find a version that satisfies the requirement django-utils==0.4.7 (from allauth-django==0.42.0) (from versions: 0.0.1, 0.0.2)
ERROR: No matching distribution found for django-utils==0.4.7 (from allauth-django==0.42.0)
If I just use pip install allauth-django, it automatically chooses version 0.42.6.
It can be simply resolved by three steps , run these commands on your terminal in given order:
pip uninstall allauth-django
pip uninstall django-allauth
pip install django-allauth
You're good to go.

i want import my file in python but can't import

First, I typed from awsdjp.boardapp.views import * but error occurred.
Full Error is:
Traceback (most recent call last):
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\management\base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\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 "C:\Users\USER\PycharmProjects\djangoProj\awsdjp\awsdjp\urls.py", line 21, in <module>
path('boardapp/',include('boardapp.urls'))
File "C:\Users\USER\PycharmProjects\djangoProj\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\USER\AppData\Local\Programs\Python\Python37\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 "C:\Users\USER\PycharmProjects\djangoProj\awsdjp\boardapp\urls.py", line 6, in <module>
from awsdjp.boardapp.views import *
ModuleNotFoundError: No module named 'awsdjp.boardapp'
I was googling about this issue .
Next, I typed
import sys
sys.path.insert(0,"C:\\Users\\USER\\PycharmProjects\\djangoProj\\")
That path is my directory's absolute path
And run but don't work ....
from awsdjp.boardapp.views import * part is not recognized.
If you want to import *, make sure that all the modules are imported in your boardapp/__init__.py
e.g.:
# boardapp/__init__.py
from . import admin
from . import apps
from . import models
from . import tests
from . import urls
from . import views
If you are trying to import from awsdjp\boardapp\urls.py, which is in the same folder as the views.py file, you can just use relative import like this:
from .views import *

Why does my Django Project not recognize apps installed on the settings?

I am trying to build my portfolio in Django and encountered an error after installing my app. It seems like it doesn't recognize the app on my INSTALLED_APPS. I've tried using 'blog' and 'blog.apps.BlogConfig' but nothing seems to be recognized.
I run the runserver with python manage.py runserver and python manage.py runserver but both returns ModuleNotFoundError: No module named 'blog.urls'
This is the whole traceback
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/urls/resolvers.py", line 398, in check
for pattern in self.url_patterns:
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/urls/resolvers.py", line 579, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/usr/django-portfolio/env/lib/python3.7/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 "/Users/usr/django-portfolio/portfolio/portfolio/urls.py", line 21, in <module>
path('', include('blog.urls'))
File "/Users/usr/django-portfolio/env/lib/python3.7/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/Users/usr/django-portfolio/env/lib/python3.7/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 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'blog.urls'
My INSTALLED_APPS is
INSTALLED_APPS = [
....
'blog'
]
URL in Settings
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('blog.urls'))
]
No module named 'blog.urls' means you don't have urls module inside blog.
You need to create a file named urls.py inside the blog app.
And you need to define some routes there.
After that below line
path('', include('blog.urls'))
will work fine.
Make sure you have structured your blog app and parent app properly. And you module path is set properly. For reference you can also see
Django Installed Apps Location

Categories