Getting Error when starting my Django server - python

I wrote new models, made migrations, migrated the models but forgot to register the models in the admin.py file. After migrating I started my server and got the following error:
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Bilawal Hassan\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Bilawal Hassan\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = self._run_checks(
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\urls\resolvers.py", line 407, in check
for pattern in self.url_patterns:
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\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\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Bilawal Hassan\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\Bilawal Hassan\PycharmProjects\Ecommerce Website\ecommerce\ecommerce\urls.py", line 27, in <module>
path('',include(('foodapp.urls', 'foodapp'), namespace='foodapp')),
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Bilawal Hassan\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 779, in exec_module
File "<frozen importlib._bootstrap_external>", line 916, in get_code
File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
ValueError: source code string cannot contain null bytes
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 "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\base.py", line 369, in execute
output = self.handle(*args, **options)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 599, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 584, in start_django
reloader.run(django_main_thread)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 299, in run
self.run_loop()
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 305, in run_loop
next(ticker)
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 345, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 361, in snapshot_files
for file in self.watched_files():
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 260, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\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\Bilawal Hassan\PycharmProjects\Ecommerce Website\venv\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Users\Bilawal Hassan\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1172, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Users\Bilawal Hassan\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>'
After getting this error I deleted my latest migration.py file but still getting the above exceptions while running my server.

Your issue is in the file C:\Users\Bilawal Hassan\PycharmProjects\Ecommerce Website\ecommerce\ecommerce\urls.py in line 27:
path('',include(('foodapp.urls', 'foodapp'), namespace='foodapp')),
Looks like Django can't find the foodapp app, check if the app is installed, you haven't any typo, etc

delete your database,then use command python manage.py showmigrations
if migrations are not made then use the migrate commands,otherwise delete both migration file and database file.then create migrations.py and include init.py in it.then run migration commands.it will fix.

Related

How to adding PDF for Admin to view Orders

I have tried to add the option to view order through PDF in the admin panel but I am getting error which I do not know the reason for nor how to fix it.
This is what I did step by step. The issue is now that I have tried restart everything but I am still getting the error.
$ pip install weasyprint django-import-export
then I added it in the installed apps 'import_export',
Here is the admin.py
def order_pdf(obj):
return mark_safe('PDF'.format(reverse('orders:admin_order_pdf', args=[obj.id])))
order_pdf.short_description = 'Order PDF'
class OrderAdmin(ImportExportActionModelAdmin):
list_display = ['id', order_pdf]
here is the views.py
#staff_member_required
def admin_order_pdf(request,order_id):
Order = get_object_or_404(order,id=order_id)
html = render_to_string('order/pdf.html',{'order':Order})
response = HttpResponse(content_type='application/pdf')
response['Content-Disposition'] = 'filename="order_{}.pdf"'.format(Order.id)
# weasyprint.HTML(string=html).write_pdf(response,stylesheets=[weasyprint.CSS(settings.STATIC_ROOT + 'css/pdf.css')])
weasyprint.HTML(string=html).write_pdf(response,stylesheets=[weasyprint.CSS(settings.STATIC_ROOT)])
return response
here is the url.py
path('admin/order/(?P<order_id>\d+)/pdf/$', views.admin_order_pdf, name='admin_order_pdf')
Here is the traceback
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\A_K\Desktop\Project 4.3\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\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\A_K\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 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\A_K\Desktop\Project 4.3\Moustiques\urls.py", line 15, in <module>
path('', include('core.urls', namespace='core')),
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\A_K\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 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
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\A_K\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
self.run()
File "C:\Users\A_K\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
File "C:\Users\A_K\Desktop\Project 4.3\core\urls.py", line 3, in <module>
self._target(*self._args, **self._kwargs)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
from . import views
File "C:\Users\A_K\Desktop\Project 4.3\core\views.py", line 6, in <module>
fn(*args, **kwargs)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
import weasyprint
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\weasyprint\__init__.py", line 440, in <module>
self.check(display_num_errors=True)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\base.py", line 387, in check
from .css import preprocess_stylesheet # noqa isort:skip
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\weasyprint\css\__init__.py", line 30, in <module>
all_issues = self._run_checks(
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
from . import computed_values, media_queries
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\weasyprint\css\computed_values.py", line 18, in <module>
return checks.run_checks(**kwargs)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
from .. import text
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\weasyprint\text.py", line 14, in <module>
new_errors = check(app_configs=app_configs)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
import cairocffi as cairo
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\cairocffi\__init__.py", line 48, in <module>
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
cairo = dlopen(
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\cairocffi\__init__.py", line 45, in dlopen
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\utils\functional.py", line 80, in __get__
raise OSError(error_message) # pragma: no cover
OSError: no library called "cairo" was found
no library called "libcairo-2" was found
cannot load library 'libcairo.so': error 0x7e
cannot load library 'libcairo.2.dylib': error 0x7e
cannot load library 'libcairo-2.dll': error 0x7e res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\A_K\Desktop\Project 4.3\venv\lib\site-packages\django\urls\resolvers.py", line 571, in url_patterns
weasyprint or django-import-export is dependent on libcairo is a shared library. Some python packages are automatically compiled with all the dependencies, but this is not the case. If you don't want to figure out how to install libcairo yourself, I would suggest that you use Anaconda, which does a good job at installing dependencies on Windows.
https://www.anaconda.com/products/individual
I verified that Anaconda has the cairocffi package, which is the python wrapper around the libcairo that triggers the error.
https://anaconda.org/conda-forge/cairocffi

Django project failed to start syntax error '<frozen importlib._bootstrap>'

i just wanted to start project in django, but it failed with this code can anyone explain me what's wrong here, i am newbie in django pls help. And if you ask a can share with code that contains in documents. I've edited standard files and created some new files like urls.py and many inserted code for starting project. but it fails everytime when i start
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\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\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py", line 408, in check
for pattern in self.url_patterns:
File "C:\Users\Bakhtyar\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\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py", line 589, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\Bakhtyar\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\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\resolvers.py", line 582, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Bakhtyar\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 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\Bakhtyar\desktop\django\myfirst\myfirst\urls.py", line 20, in <module>
path('articles/', include('articles.urls')),
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Bakhtyar\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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'articles'
Traceback (most recent call last):
File "manage.py", line 24, in <module>
main()
File "manage.py", line 20, in main
execute_from_command_line(sys.argv)
File "C:\Users\Bakhtyar\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\Bakhtyar\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\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle
self.run(**options)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 613, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 598, in start_django
reloader.run(django_main_thread)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 313, in run
self.run_loop()
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 319, in run_loop
next(ticker)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 359, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 375, in snapshot_files
for file in self.watched_files():
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 274, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\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\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\pathlib.py", line 1177, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Users\Bakhtyar\AppData\Local\Programs\Python\Python38-32\lib\pathlib.py", line 200, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] Синтаксическая ошибка в имени файла, имени папки или метке тома: '<frozen importlib._bootstrap>'
The problem you have is that you're importing a non-existing module.
ModuleNotFoundError: No module named 'articles'
Check your imports and look where you're importing articles and fix that accordingly (rename if it's a misspell or change it to the correct name).

Have received the following error while reusing movie app in my django project

I am using windows 10 python 3.7.3 and django 2.7.2 ,I am new to Django. Want to reuse the movie app "https://github.com/nathanborror/django-basic-apps/tree/master/basic " in my project.
Steps done before running the manage.py runserver:
1) Copied the folder in my django project directory
2) Have added the app in the Installed apps in Settings.py
3) Have updated the apps url in the urls.py file of my main django project
4) Have checked from the git repo page , no additional dependancy to be downloaded.
Error after running manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Users\dhaval1.desai\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 953, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
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 'pollsdjango-basic-apps-master'
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 577, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 562, in start_django
reloader.run(django_main_thread)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 280, in run
self.run_loop()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 286, in run_loop
next(ticker)
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 326, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 342, in snapshot_files
for file in self.watched_files():
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 241, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 128, in iter_modules_and_files
if not path.exists():
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 1339, in exists
self.stat()
File "C:\Users\dhaval1.desai\AppData\Local\Programs\Python\Python37\lib\pathlib.py", line 1161, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
Help will be very much appreciated.

LookupError: No installed app with label 'admin'. when I tried running a program using Django

I was trying to run a python program on my computer, the command I use is
py -3 manage.py runserver,
but I ran into an error and I couldn't find any helpful posts online that can solve this problem.
Python version is Python 3.7.3
Django version is 2.2
Here is the error message:
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\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\Desktop\Intern\Diversity_Policy_Site\blog\models.py", line 4, in <module>
from .search import PolicyIndex
File "C:\Users\Desktop\Intern\Diversity_Policy_Site\blog\search.py", line 14, in <module>
connections.create_connection(hosts=["https://dd90577b842c4f9396ca1846612e98df.us-east-1.aws.found.io:9243"], http_auth=('elastic', 'Mq2jdfPLSRG1m8qxp4vd0qNa'))
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch_dsl\connections.py", line 66, in create_connection
conn = self._conns[alias] = Elasticsearch(**kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch\client\__init__.py", line 206, in __init__
self.transport = transport_class(_normalize_hosts(hosts), **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch\transport.py", line 108, in __init__
self.set_connections(hosts)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch\transport.py", line 157, in set_connections
connections = list(zip(connections, hosts))
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch\transport.py", line 154, in _create_connection
return self.connection_class(**kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\elasticsearch\connection\http_urllib3.py", line 161, in __init__
"Root certificates are missing for certificate "
elasticsearch.exceptions.ImproperlyConfigured: Root certificates are missing for certificate validation. Either pass them in using the ca_certs parameter or install certifi to use it automatically.
Traceback (most recent call last):
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label]
KeyError: 'admin'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\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\Desktop\Intern\Diversity_Policy_Site\mysite\urls.py", line 22, in <module>
path('admin/', admin.site.urls),
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup()
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
File "C:\Users\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message)
LookupError: No installed app with label 'admin'.
The above code is the error I have, the posts I found online were not helpful.
type this command in cmd:
pip install certifi
and the above error should be solved.

Getting error for created new app in python

i am new in python, I have created new app as crud, i am using django, app is created, but when i run the server it gives me below error, not getting what exactl error in that, In mysite/settings.py i have added in INSTALLED_APPS added crud.apps.CrudConfig still getting this error
C:\Users\Nikul\PycharmProjects\mysite>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py", line 134, in create
% (mod_path, cls_name, ', '.join(candidates))
django.core.exceptions.ImproperlyConfigured: 'crud.apps' does not contain a class 'CrudConfig'. Choices are: 'PollsConfig'.
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 "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\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\Nikul\PycharmProjects\mysite\mysite\urls.py", line 22, in <module>
path('crud/', include('crud.urls')),
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\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\Nikul\PycharmProjects\mysite\crud\urls.py", line 3, in <module>
from . import views
File "C:\Users\Nikul\PycharmProjects\mysite\crud\views.py", line 8, in <module>
from .models import Choice, Question
File "C:\Users\Nikul\PycharmProjects\mysite\crud\models.py", line 8, in <module>
class Question(models.Model):
File "C:\Users\Nikul\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\db\models\base.py", line 111, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class crud.models.Question doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
Can anyone please help me what we need to do to resolve that error ?

Categories

Resources