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
Related
Here is the errors
I have installed and created virtualenv as same like the one on Windows and replaced it on Ubuntu with that new one. I could activate the virtual but when I do python3 manage.py runserver it gives error as like below. If someone help, it will be grateful.
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 "/home/pema/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 61, in execute
super().execute(*args, **options)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/base.py", line 398, in execute
output = self.handle(*args, **options)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 96, in handle
self.run(**options)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 105, in run
self.inner_run(None, **options)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/management/base.py", line 423, in check
databases=databases,
File "/home/pema/.local/lib/python3.6/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/pema/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/pema/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 416, in check
for pattern in self.url_patterns:
File "/home/pema/.local/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pema/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 602, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/pema/.local/lib/python3.6/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/pema/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 595, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/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/pema/Desktop/Django/devsearch/devsearch/urls.py", line 9, in <module>
path("", include("users.urls"))
File "/home/pema/.local/lib/python3.6/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/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/pema/Desktop/Django/devsearch/users/urls.py", line 3, in <module>
from. import views
File "/home/pema/Desktop/Django/devsearch/users/views.py", line 8, in <module>
from .forms import CustomUserCreationForm, ProfileForm, SkillForm
File "/home/pema/Desktop/Django/devsearch/users/forms.py", line 1, in <module>
from dataclasses import fields
ModuleNotFoundError: No module named 'dataclasses'
Data classes were introduced in Python 3.7. You are running Python 3.6.
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).
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.
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 ?
I'm running wagtail in a virtualenvwrapper on my machine. The requirements all install as needed
Django>=2.0,<2.1
wagtail>=2.0,<2.1
I've even started this process over again by completely uninstalling django and wagtail. After reinstall wagtail, I run wagtail start mysite, cd into my directory and run python manage.py migrate. This is what I see:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/base.py", line 332, in execute
self.check()
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 58, in _run_checks
issues.extend(super()._run_checks(**kwargs))
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/johnbriggs/.virtualenvs/wagtail/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 "/Users/johnbriggs/Sites/wagtail/farts/farts/urls.py", line 5, in <module>
from wagtail.admin import urls as wagtailadmin_urls
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/wagtail/admin/urls/__init__.py", line 13, in <module>
from wagtail.admin.api import urls as api_urls
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/wagtail/admin/api/urls.py", line 6, in <module>
from .endpoints import PagesAdminAPIEndpoint
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/wagtail/admin/api/endpoints.py", line 3, in <module>
from wagtail.api.v2.endpoints import PagesAPIEndpoint
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/wagtail/api/v2/endpoints.py", line 9, in <module>
from rest_framework.renderers import BrowsableAPIRenderer, JSONRenderer
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/rest_framework/renderers.py", line 25, in <module>
from rest_framework import VERSION, exceptions, serializers, status
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/rest_framework/exceptions.py", line 17, in <module>
from rest_framework.utils.serializer_helpers import ReturnDict, ReturnList
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/rest_framework/utils/serializer_helpers.py", line 9, in <module>
from rest_framework.compat import unicode_to_repr
File "/Users/johnbriggs/.virtualenvs/wagtail/lib/python3.6/site-packages/rest_framework/compat.py", line 26, in <module>
from django.core.urlresolvers import ( # Will be removed in Django 2.0
ModuleNotFoundError: No module named 'django.core.urlresolvers'
I haven't added in any custom code.. this is a from-the-start installation. What is causing this error?
It turns out that djangorestframework was an older version. It was most definitely not a duplicate of the question suggested but I was able to solve it by upgrading my version (as suggested by #Alexy). I'm leaving this up in case someone else has a similar issue.