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'))
Related
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
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
I am using the DJango framework. I created a project in school using Pycharm and I wanted to create another project. However, when trying to run my server, all of the sudden I start to get the following error in my command prompt:
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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 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 "C:\Users\Johnny\PycharmProjects\DJango Tutorial V2\mysite\mysite\urls.py", line 20, in <module>
path('polls/', include('polls.url')),
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.url'
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 "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle
self.run(**options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 613, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 598, in start_django
reloader.run(django_main_thread)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 313, in run
self.run_loop()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 319, in run_loop
next(ticker)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 359, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 375, in snapshot_files
for file in self.watched_files():
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 274, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1177, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 200, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
In my past project, I did have bootstrap installed but now I am not using it. I am also using a different python project interpreter. Why is it not working?
EDIT: Here is the error printed out:
C:\Users\Johnny\PycharmProjects\DJango Tutorial V2\mysite>python manage.py makemigrations
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 "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 368, in execute
self.check()
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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 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 "C:\Users\Johnny\PycharmProjects\DJango Tutorial V2\mysite\mysite\urls.py", line 20, in <module>
path('polls/', include('polls.url')),
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Johnny\AppData\Local\Programs\Python\Python38\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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'polls.url'
First of all check if you have incorrect file names for apps in INSTALLED APPS in settings.py. Your app should be sthg like:
INSTALLED_APPS = [
'home.apps.HomeConfig' # or simply 'home' assuming all your app name,
......
]
Then, restart the server, if everything is good and still does not work.
In some cases the error is also shown because of migration. Try making migrations. Like:
python manage.py makemigrations
python manage.py migrate
You should be good to go by now.
Found it. Instead of polls.url, I wrote poll.url inside the url.py for the mysite package. Watch your spelling!
In my case, it was some corrupted migrations file. I deleted it and ran migrations afresh.
My folder in App was url.py
and in project setting i was writing path('', include('loginaccounts.urls')).
In path when I changed to url from urls it worked as it was not able to map the path.
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 *
I am struggling with a problem in using django. When I type python manage.py runserver, it holds for few seconds and keeps giving me a following message:
RuntimeError: Model class upload.models.ImgParent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
I searched similar problems on the internet and tried to add 'upload.models.ImgParent' on INSTALLED_APPS in settings.py but it still doesn't work.
My current INSTALLED_APPS in settings.py looks like this:
INSTALLED_APPS = [
'search.apps.SearchConfig',
'upload.apps.UploadConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'mod_wsgi.server',
'home',
]
and my apps.py looks like this:
class UploadConfig(AppConfig):
name = 'upload'
edit, this is full traceback:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/apps/config.py", line 134, in create
% (mod_path, cls_name, ', '.join(candidates))
django.core.exceptions.ImproperlyConfigured: 'upload.apps' does not contain a class 'uploadConfig'. Choices are: 'UploadConfig'.
Traceback (most recent call last):
File "manage.py", line 19, in <module>
execute_from_command_line(sys.argv)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/urls/resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "/home/edwardkim/syseng/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/projectsite/urls.py", line 23, in <module>
path('search/', include('search.urls')),
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/edwardkim/syseng/venv/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/search/urls.py", line 3, in <module>
from . import views
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/search/views.py", line 2, in <module>
from upload.models import Img
File "/home/edwardkim/syseng/Foram_Tagger_Team43_Software/projectsite/upload/models.py", line 3, in <module>
class ImgParent(models.Model):
File "/home/edwardkim/syseng/venv/lib/python3.6/site-packages/django/db/models/base.py", line 111, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class upload.models.ImgParent doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Please help with my problem and let me know if you need any additional information. Thank you.