Related
I am currently going through 'The Definitive Guide to Celery and Django' course by testdriven.io. I've managed to containerize the whole application. Everything was built correctly and seemed to work just fine, but when I tried to enter the Django shell and run a task, to ensure everything works correctly, the following error appeared.
>>> divide.delay(1, 2)
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 30, in __call__
return self.__value__
AttributeError: 'ChannelPromise' object has no attribute '__value__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 446, in _reraise_as_library_errors
yield
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 433, in _ensure_connection
return retry_over_time(
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 312, in retry_over_time
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 877, in _connection_factory
self._connection = self._establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 812, in _establish_connection
conn = self.transport.establish_connection()
File "/usr/local/lib/python3.10/site-packages/kombu/transport/pyamqp.py", line 201, in establish_connection
conn.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/connection.py", line 323, in connect
self.transport.connect()
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 129, in connect
self._connect(self.host, self.port, self.connect_timeout)
File "/usr/local/lib/python3.10/site-packages/amqp/transport.py", line 184, in _connect
self.sock.connect(sa)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 425, in delay
return self.apply_async(args, kwargs)
File "/usr/local/lib/python3.10/site-packages/celery/app/task.py", line 575, in apply_async
return app.send_task(
File "/usr/local/lib/python3.10/site-packages/celery/app/base.py", line 788, in send_task
amqp.send_task_message(P, name, message, **options)
File "/usr/local/lib/python3.10/site-packages/celery/app/amqp.py", line 510, in send_task_message
ret = producer.publish(
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 177, in publish
return _publish(
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 523, in _ensured
return fun(*args, **kwargs)
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 186, in _publish
channel = self.channel
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 209, in _get_channel
channel = self._channel = channel()
File "/usr/local/lib/python3.10/site-packages/kombu/utils/functional.py", line 32, in __call__
value = self.__value__ = self.__contract__()
File "/usr/local/lib/python3.10/site-packages/kombu/messaging.py", line 225, in <lambda>
channel = ChannelPromise(lambda: connection.default_channel)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 895, in default_channel
self._ensure_connection(**conn_opts)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 432, in _ensure_connection
with ctx():
File "/usr/local/lib/python3.10/contextlib.py", line 153, in __exit__
self.gen.throw(typ, value, traceback)
File "/usr/local/lib/python3.10/site-packages/kombu/connection.py", line 450, in _reraise_as_library_errors
raise ConnectionError(str(exc)) from exc
kombu.exceptions.OperationalError: [Errno 111] Connection refused
I've done a quick research and in most cases it seemed to be a lack of the following lines
from config.celery import app as celery_app
__all__ = ['celery_app']
in the config.__init__.py, but it's clearly not an issue here.
I also double checked whether redis container is up and listening on port 6379.
The only difference between my code and the course code is that I decided to use Poetry package manager instead of requirements.txt file and pip.
At this point I am a little bit confused I'll be thankful for any tip. You can find the whole code below:
https://github.com/Kibraks/django-celery-app
I am trying to mock simple Glacier calls (creation and deletion of a Glacier vault) and can't find my way around this (despite being able to achieve such simple mocking with S3, creating a Bucket).
It seems that the mocking of Glacier simply isn't taken into account.
Code is as follows:
import boto3
from moto import mock_glacier
with mock_glacier():
glacier_resource = boto3.resource('glacier', region_name="fake-glacier-region")
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
And I get the following exception at vault creation:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/<...>/test_mock_glacier.py", line 9, in test_simplest
vault = glacier_resource.create_vault(accountId='-', vaultName="fake.glacier.name")
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/factory.py", line 520, in do_action
response = action(self, *args, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/boto3/resources/action.py", line 83, in __call__
response = getattr(parent.meta.client, operation_name)(*args, **params)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 663, in _make_api_call
operation_model, request_dict, request_context)
File "/<...>/.local/lib/python3.7/site-packages/botocore/client.py", line 682, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 137, in _send_request
success_response, exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 256, in _needs_retry
caught_exception=caught_exception, request_dict=request_dict)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 251, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 317, in __call__
caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 223, in __call__
attempt_number, caught_exception)
File "/<...>/.local/lib/python3.7/site-packages/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/<...>/.local/lib/python3.7/site-packages/botocore/httpsession.py", line 343, in send
raise EndpointConnectionError(endpoint_url=request.url, error=e)
botocore.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://glacier.fake-glacier-region.amazonaws.com/-/vaults/fake.glacier.name"
I am using boto3 v1.17.49 and moto v2.0.8 that I installed using python3.7 -m pip install 'moto[all]'
Providing a valid AWS region name leads to following exception:
botocore.exceptions.ClientError: An error occurred (UnrecognizedClientException) when calling the CreateVault operation: The security token included in the request is invalid.
(while having set mock AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_SECURITY_TOKEN, AWS_SESSION_TOKEN environment variables (with 'testing' as value) as stated in moto's README)
I turned out to be a bug where a Glacier vault can not contain a . in its name.
A fix is on its way (merged into master, to be released with version 2.0.9)
Quickfix was thus to change vaultName="fake.glacier.name" to vaultName="fakeGlacierName".
EDIT
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, sessions
Running migrations:
Applying authtoken.0001_initial... OK
Applying authtoken.0002_auto_20160226_1747... OK
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\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\utils.py", line 224, in close_all
connection.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
I learn about Django API REST and have implemented the quickstart project (https://www.django-rest-framework.org/tutorial/quickstart/).
It works fine locally but I would like to use API with Postman but it dose'nt works
I got 401 Unauthorized error
I try adding 'DEFAULT_AUTHENTICATION_CLASSES' key in settings.py but dose'nt works neither
settings.py
INSTALLED_APPS = [
'rest_framework',
'rest_framework.authtoken',
]
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.TokenAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination',
'PAGE_SIZE': 10
}
moreover, I have a huge traceback in terminal when saving projects (below), even if py manage.py runserver works
Traceback (most recent call last):
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 196, in finish_response
self.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\simple_server.py", line 38, in close
SimpleHandler.close(self)
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 334, in close
self.result.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\http\response.py", line 252, in close
signals.request_finished.send(sender=self._handler_class)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\dispatch\dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\dispatch\dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\__init__.py", line 57, in close_old_connections
conn.close_if_unusable_or_obsolete()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\base\base.py", line 514, in close_if_unusable_or_obsolete
self.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
[02/Sep/2020 16:34:13] "GET /users/ HTTP/1.1" 500 59
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 57191)
Traceback (most recent call last):
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 138, in run
self.finish_response()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 196, in finish_response
self.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\servers\basehttp.py", line 111, in close
super().close()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\simple_server.py", line 38, in close
SimpleHandler.close(self)
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 334, in close
self.result.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\http\response.py", line 252, in close
signals.request_finished.send(sender=self._handler_class)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\dispatch\dispatcher.py", line 175, in send
for receiver in self._live_receivers(sender)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\dispatch\dispatcher.py", line 175, in <listcomp>
for receiver in self._live_receivers(sender)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\__init__.py", line 57, in close_old_connections
conn.close_if_unusable_or_obsolete()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\base\base.py", line 514, in close_if_unusable_or_obsolete
self.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 650, in process_request_thread
self.finish_request(request, client_address)
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 360, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\socketserver.py", line 720, in __init__
self.handle()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle
self.handle_one_request()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\servers\basehttp.py", line 194, in handle_one_request
handler.run(self.server.get_app())
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 145, in run
self.handle_error()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\servers\basehttp.py", line 116, in handle_error
super().handle_error()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 381, in handle_error
self.finish_response()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 184, in finish_response
self.write(data)
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 287, in write
self.send_headers()
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 344, in send_headers
if not self.origin_server or self.client_is_modern():
File "C:\Users\jl3.PRT-063\AppData\Local\Programs\Python\Python37-32\lib\wsgiref\handlers.py", line 357, in client_is_modern
return self.environ['SERVER_PROTOCOL'].upper() != 'HTTP/0.9'
TypeError: 'NoneType' object is not subscriptable
----------------------------------------
D:\Users\jl3\DevSpace\api_django\tutorial\settings.py changed, reloading.
Traceback (most recent call last):
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 301, in run
self.run_loop()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop
next(ticker)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 355, in tick
self.notify_file_changed(filepath)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 330, in notify_file_changed
trigger_reload(path)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 218, in trigger_reload
sys.exit(3)
SystemExit: 3
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\utils.py", line 224, in close_all
connection.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
Traceback (most recent call last):
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\utils\autoreload.py", line 601, in run_with_reloader
sys.exit(exit_code)
SystemExit: 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\core\management\base.py", line 336, in run_from_argv
connections.close_all()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\utils.py", line 224, in close_all
connection.close()
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 248, in close
if not self.is_in_memory_db():
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\base.py", line 367, in is_in_memory_db
return self.creation.is_in_memory_db(self.settings_dict['NAME'])
File "C:\Users\jl3.PRT-063\Desktop\Python\Django\env\lib\site-packages\django\db\backends\sqlite3\creation.py", line 12, in is_in_memory_db
return database_name == ':memory:' or 'mode=memory' in database_name
TypeError: argument of type 'WindowsPath' is not iterable
First, you are going to have to create a token for the user you are trying to log in as.
from rest_framework.authtoken.models import Token
token = Token.objects.create(user=...)
print(token.key)
Then you want to include that token in your url head
curl -X GET http://127.0.0.1:8000/api/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
Here is some documentation look under TokenAuthentication.
https://www.django-rest-framework.org/api-guide/authentication/
In post man you can just click the header box and type in your token there. This should authenticate you, you just have to generate the token for your user first.
Here is a link to some documentation on how to work with common authentication types with postman. https://learning.postman.com/docs/sending-requests/authorization/#basic-auth
Try this one.
python3 manage.py migrate
I'm using haystack and solr on Django. I get UnicodeDecodeError and I think the reason is the unicode data in the database are either converted to str or decoded to utf-8 which makes a later UnicodeDecodeError when sending via httplib or printing to the console.
I think the problem should before the haystack full_prepare function, since as I checked afterwards data is already ruined.
Any thoughts?
I setup.pyed install (haystack, pysolr, django)
and used the binary of lxml from http://www.lfd.uci.edu/~gohlke/pythonlibs/
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Pouria\Desktop\conference\conference>python manage.py rebuild_index
WARNING: This will irreparably remove EVERYTHING from your search index in connection 'default'.
Your choices after this are to restore from backups or rebuild via the `rebuild_index` command.
Are you sure you wish to continue? [y/N] y
Removing all documents from your index because you said so.
Failed to clear Solr index: [Reason: Error 404 Not Found]
All documents removed.
C:\Python27\lib\site-packages\django\db\models\fields\__init__.py:808: RuntimeWarning: DateTimeField
received a naive datetime (2013-02-09 08:47:27.110000) while time zone support is active.
RuntimeWarning)
Indexing 2 conferences.
ERROR:root:Error updating conferences using default
Traceback (most recent call last):
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 210, in handle_label
self.update_backend(label, using)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 256, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 78, in do_update
backend.update(index, current_qs)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\backends\solr_backend.py", line 72, i
n update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "C:\Python27\lib\site-packages\pysolr.py", line 786, in add
return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
File "C:\Python27\lib\site-packages\pysolr.py", line 379, in _update
return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
File "C:\Python27\lib\site-packages\pysolr.py", line 291, in _send_request
timeout=self.timeout)
File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies
)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 373, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 171, in send
timeout=timeout
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 421, in url
open
body=body, headers=headers)
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 273, in _ma
ke_request
conn.request(method, url, **httplib_request_kw)
File "C:\Python27\lib\httplib.py", line 949, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 990, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 943, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 810, in _send_output
self.send(message_body)
File "C:\Python27\lib\httplib.py", line 775, in send
self.sock.sendall(str)
File "C:\Python27\lib\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143-149: ordinal not in range(
128)
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 443, in execute_from
_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\rebuild_index.py"
, line 15, in handle
call_command('update_index', **options)
File "C:\Python27\lib\site-packages\django\core\management\__init__.py", line 150, in call_command
return klass.execute(*args, **defaults)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 232, in execute
output = self.handle(*args, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 184, in handle
return super(Command, self).handle(*items, **options)
File "C:\Python27\lib\site-packages\django\core\management\base.py", line 341, in handle
label_output = self.handle_label(label, **options)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 210, in handle_label
self.update_backend(label, using)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 256, in update_backend
do_update(backend, index, qs, start, end, total, self.verbosity)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\management\commands\update_index.py",
line 78, in do_update
backend.update(index, current_qs)
File "C:\Users\Pouria\Desktop\conference\conference\haystack\backends\solr_backend.py", line 72, i
n update
self.conn.add(docs, commit=commit, boost=index.get_field_weights())
File "C:\Python27\lib\site-packages\pysolr.py", line 786, in add
return self._update(m, commit=commit, waitFlush=waitFlush, waitSearcher=waitSearcher)
File "C:\Python27\lib\site-packages\pysolr.py", line 379, in _update
return self._send_request('post', path, message, {'Content-type': 'text/xml; charset=utf-8'})
File "C:\Python27\lib\site-packages\pysolr.py", line 291, in _send_request
timeout=self.timeout)
File "C:\Python27\lib\site-packages\requests\api.py", line 87, in post
return request('post', url, data=data, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 279, in request
resp = self.send(prep, stream=stream, timeout=timeout, verify=verify, cert=cert, proxies=proxies
)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 373, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 171, in send
timeout=timeout
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 421, in url
open
body=body, headers=headers)
File "C:\Python27\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 273, in _ma
ke_request
conn.request(method, url, **httplib_request_kw)
File "C:\Python27\lib\httplib.py", line 949, in request
self._send_request(method, url, body, headers)
File "C:\Python27\lib\httplib.py", line 990, in _send_request
self.endheaders(body)
File "C:\Python27\lib\httplib.py", line 943, in endheaders
self._send_output(message_body)
File "C:\Python27\lib\httplib.py", line 810, in _send_output
self.send(message_body)
File "C:\Python27\lib\httplib.py", line 775, in send
self.sock.sendall(str)
File "C:\Python27\lib\socket.py", line 222, in meth
return getattr(self._sock,name)(*args)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 143-149: ordinal not in range(
128)
I had the same error. It's seams to be fixed on master https://github.com/toastdriven/django-haystack. So you should use haystack 2.0 alpha/beta.
Django noob. Can you tell me what I am doing wrong here? I looked this up on google, and the closest issue I found was this and this -- but couldn't figure it out.
Is this a password issue? I have the mysql password on my settings.py
I appreciate your help.
j#ime:~/dotcloud$ dotcloud run jims.www python current/jims/manage.py syncdb
# python current/jims/manage.py syncdb
Traceback (most recent call last):
File "current/jims/manage.py", line 14, in <module>
execute_manager(settings)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 219, in execute
self.validate()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/core/management/validation.py", line 102, in get_validation_errors
connection.validation.validate_field(e, opts, f)
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/validation.py", line 14, in validate_field
db_version = self.connection.get_server_version()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 338, in get_server_version
self.cursor()
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/__init__.py", line 250, in cursor
cursor = self.make_debug_cursor(self._cursor())
File "/home/dotcloud/env/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 322, in _cursor
self.connection = Database.connect(**kwargs)
File "/home/dotcloud/env/lib/python2.6/site-packages/MySQLdb/__init__.py", line 81, in Connect
return Connection(*args, **kwargs)
File "/home/dotcloud/env/lib/python2.6/site-packages/MySQLdb/connections.py", line 187, in __init__
super(Connection, self).__init__(*args, **kwargs2)
_mysql_exceptions.OperationalError: (1045, "Access denied for user 'jims'#'ip-10-68-47-216.ec2.internal' (using password: YES)")
Abort.