My app image upload works very well on localhost but when I deployed to Heroku, it gives me Attribute Error and Runtime Error. How do I solve this?
I remove the validators on the filefield in my form as suggested by some people here but it did not solve the problem
##########
#views.py
def add_post():
form = AddPostForm()
if request.method == 'POST':
if form.validate_on_submit():
filename = images.save(request.files['post_image'])
url = images.url(filename)
new_post = Post( form.post_title.data,
form.post_description.data,
current_user.id, form.is_public.data,
filename, url, form.Share_location.data,
form.home_delivery.data, form.share_date.data,
form.total_slot.data, form.slot_value.data,
form.payable_amount.data, form.no_of_months.data,
form.no_of_weeks.data, form.no_of_days.data,
form.month_sub.data, form.week_sub.data,
form.day__sub.data)
db.session.add(new_post)
db.session.commit()
flash('New shared Item, {}, added!'.format(new_post.post_title),
'success')
return redirect(url_for('posts.public_posts'))
else:
flash_errors(form)
flash('ERROR! Share item was not added.', 'error')
return render_template('add_post.html', title='Add Item', form=form)
#############
#__init__.py
app = Flask(__name__, instance_relative_config=True)
if isfile(join('instance', 'flask_full.cfg')):
app.config.from_pyfile('flask_full.cfg')
else:
app.config.from_pyfile('flask.cfg')
app.config.from_pyfile('flask.cfg')
db = SQLAlchemy(app)
images = UploadSet('images', IMAGES)
configure_uploads(app, images)
#flask.cfg
UPLOADS_DEFAULT_DEST = TOP_LEVEL_DIR + '/project/static/img/'
UPLOADED_IMAGES_URL = 'https://bulkieshare.herokuapp.com/static/img/'
UPLOADED_IMAGES_DEST = TOP_LEVEL_DIR + '/project/static/img/'
UPLOADED_IMAGES_URL = 'https://bulkieshare.herokuapp.com/static/img/'
I want to successfully upload an image file to my remote database but I kept getting these error messages from Heroku.
#Here is the error message:
[2019-07-12 09:08:40 +0000] [16] [ERROR] Error handling request /add
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-packages/flask_uploads.py",
line 327, in config
return current_app.upload_set_config[self.name]
File "/app/.heroku/python/lib/python3.6/site-packages/werkzeug/local.py",
line 347, in __getattr__
return getattr(self._get_current_object(), name)
AttributeError: 'Flask' object has no attribute 'upload_set_config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/app/.heroku/python/lib/python3.6/site-
packages/gunicorn/workers/sync.py", line 135, in handle
self.handle_request(listener, req, client, addr)
File "/app/.heroku/python/lib/python3.6/site-
packages/gunicorn/workers/sync.py", line 176, in handle_request
respiter = self.wsgi(environ, resp.start_response)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
2309, in __call__
return self.wsgi_app(environ, start_response)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
2295, in wsgi_app
response = self.handle_exception(e)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
1741, in handle_exception
reraise(exc_type, exc_value, tb)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py",
line 35, in reraise
raise value
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
2292, in wsgi_app
response = self.full_dispatch_request()
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
1815, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
1718, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/app/.heroku/python/lib/python3.6/site-packages/flask/_compat.py",
line 35, in reraise
raise value
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
1813, in full_dispatch_request
rv = self.dispatch_request()
File "/app/.heroku/python/lib/python3.6/site-packages/flask/app.py", line
1799, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/app/.heroku/python/lib/python3.6/site-
packages/flask_login/utils.py", line 261, in decorated_view
return func(*args, **kwargs)
File "/app/project/posts/views.py", line 68, in add_post
filename = images.save(request.files['post_image'])
File "/app/.heroku/python/lib/python3.6/site-packages/flask_uploads.py",
line 414, in save
if not self.file_allowed(storage, basename):
File "/app/.heroku/python/lib/python3.6/site-packages/flask_uploads.py",
line 370, in file_allowed
return self.extension_allowed(extension(basename))
File "/app/.heroku/python/lib/python3.6/site-packages/flask_uploads.py",
line 380, in extension_allowed
return ((ext in self.config.allow) or
File "/app/.heroku/python/lib/python3.6/site-packages/flask_uploads.py",
line 329, in config
raise RuntimeError("cannot access configuration outside request")
RuntimeError: cannot access configuration outside request
10.31.79.212 - - [12/Jul/2019:09:08:40 +0000] "POST /add HTTP/1.1" 500 0
"-" "-"
Related
I have that code for grid connection later I want to test some basic page, but Im stucked with basic auth for grid connection how can be HOST not Specified error when there is a HOST:
browser = webdriver.Remote('https://username:password!#selenium.tools.grid.io/wd/hub',
options=options)
desired_capabilities={
"browserName": "chrome",
"browserVersion": "latest",
"video": "True",
"platform": "LINUX",
})
but I got an error:
Traceback (most recent call last):
File "C:\scratches\scratch.py", line 6, in <module>
driver = webdriver.Remote(
File "C:\Users\\PycharmProjects\tests-v2\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 157, in __init__
self.start_session(capabilities, browser_profile)
File "C:\Users\\PycharmProjects\-tests-v2\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 252, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "C:\Users\\PycharmProjects\tests-v2\venv\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 319, in execute
response = self.command_executor.execute(driver_command, params)
File "C:\Users\\PycharmProjects\tests-v2\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 374, in execute
return self._request(command_info[0], url, body=data)
File "C:\Users\PycharmProjects\tests-v2\venv\lib\site-packages\selenium\webdriver\remote\remote_connection.py", line 402, in _request
resp = http.request(method, url, body=body, headers=headers)
File "C:\Users\PycharmProjects\tests-v2\venv\lib\site-packages\urllib3\request.py", line 79, in request
return self.request_encode_body(
File "C:\Users\PycharmProjects\tests-v2\venv\lib\site-packages\urllib3\request.py", line 171, in request_encode_body
return self.urlopen(method, url, **extra_kw)
File "C:\Users\PycharmProjects\tests-v2\venv\lib\site-packages\urllib3\poolmanager.py", line 325, in urlopen
conn = self.connection_from_host(u.host, port=u.port, scheme=u.scheme)
File "C:\Users\PycharmProjects\tests-v2\venv\lib\site-packages\urllib3\poolmanager.py", line 231, in connection_from_host
raise LocationValueError("No host specified.")
urllib3.exceptions.LocationValueError: No host specified.
Can someone could help me?
I have a series of AWS Lambdas that are fed from SQS queue event triggers. However, sometimes when I try to delete the message from the queue, the attempt times out over and over again until my Lambda timeout occurs.
I enabled Debug logging which confirmed it was a socket timeout, but I don't get any further details beyond that. This also appears to be irregular. At first, I thought it was a Lambda warmup issue, but I've seen the problem after running the lambda multiple times successfully and on the first deploy.
What I've tried so far:
I thought maybe using a Boto client vs a Boto resource was the problem, but I saw the same result with both methods.
I've tweaked the connection and read timeouts to be higher than the default, however, the connection just retries with the Boto retry logic under the hood.
I've tried the connection timeout to be lower, but this just means more retries before the lambda timeout.
I've tried both standard and FIFO queue types, both have the same problem
A couple of other details:
Python v3.8.5
Boto3 v1.16.1
My SQS settings are set for a 5-second delay and a 120-second visibility timeout
My lambda timeout is 120 seconds.
Snippet of the code that I'm using:
config = Config(connect_timeout=30, read_timeout=30, retries={'total_max_attempts': 1}, region_name='us-east-1')
sqs_client = boto3.client(service_name='sqs', config=config)
receiptHandle = event['Records'][0]['receiptHandle']\
fromQueueName = eventSourceARN.split(':')[-1]
fromQueue = sqs_client.get_queue_url(QueueName=fromQueueName)
fromQueueUrl = sqs_client.get_queue_url(QueueName=fromQueueName)['QueueUrl']
messageDelete = sqs_client.delete_message(QueueUrl=fromQueueUrl, ReceiptHandle=receiptHandle)
And the and example of the DEBUG exception I'm seeing:
[DEBUG] 2020-10-29T21:27:28.32Z 3c60cac9-6d99-58c6-84c9-92dc581919fd retry needed, retryable exception caught:
Connect timeout on endpoint URL: "https://queue.amazonaws.com/" Traceback (most recent call last):
"/var/task/urllib3/connection.py", line 159, in _new_conn conn = connection.create_connection(
File "/var/task/urllib3/util/connection.py", line 84, in create_connection
raise err
File "/var/task/urllib3/util/connection.py", line 74, in create_connection
sock.connect(sa) socket.timeout: timed out During handling of the above exception, another exception occurred: Traceback (most
recent call last):
File "/opt/python/botocore/httpsession.py", line 254, in send
urllib_response = conn.urlopen(
File "/var/task/urllib3/connectionpool.py", line 726, in urlopen
retries = retries.increment(
File "/var/task/urllib3/util/retry.py", line 386, in increment
raise six.reraise(type(error), error, _stacktrace)
File "/var/task/urllib3/packages/six.py", line 735, in reraise
raise value
File "/var/task/urllib3/connectionpool.py", line 670, in urlopen
httplib_response = self._make_request(
File "/var/task/urllib3/connectionpool.py", line 381, in _make_request
self._validate_conn(conn)
File "/var/task/urllib3/connectionpool.py", line 978, in _validate_conn
conn.connect()
File "/var/task/urllib3/connection.py", line 309, in connect
conn = self._new_conn()
File "/var/task/urllib3/connection.py", line 164, in _new_conn
raise ConnectTimeoutError( urllib3.exceptions.ConnectTimeoutError: (<botocore.awsrequest.AWSHTTPSConnection object at 0x7f27b56b7460>, 'Connection
to queue.amazonaws.com timed out. (connect timeout=15)') During handling of the above exception, another
exception occurred: Traceback (most recent call last):
File "/opt/python/utils.py", line 79, in preflight_check
fromQueue = sqs_client.get_queue_url(QueueName=fromQueueName)
File "/opt/python/botocore/client.py", line 357, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/opt/python/botocore/client.py", line 662, in _make_api_call
http, parsed_response = self._make_request(
File "/opt/python/botocore/client.py", line 682, in _make_request
return self._endpoint.make_request(operation_model, request_dict)
File "/opt/python/botocore/endpoint.py", line 102, in make_request
return self._send_request(request_dict, operation_model)
File "/opt/python/botocore/endpoint.py", line 136, in _send_request
while self._needs_retry(attempts, operation_model, request_dict,
File "/opt/python/botocore/endpoint.py", line 253, in _needs_retry
responses = self._event_emitter.emit(
File "/opt/python/botocore/hooks.py", line 356, in emit
return self._emitter.emit(aliased_event_name, **kwargs)
File "/opt/python/botocore/hooks.py", line 228, in emit
return self._emit(event_name, kwargs)
File "/opt/python/botocore/hooks.py", line 211, in _emit
response = handler(**kwargs)
File "/opt/python/botocore/retryhandler.py", line 183, in __call__
if self._checker(attempts, response, caught_exception):
File "/opt/python/botocore/retryhandler.py", line 250, in __call__
should_retry = self._should_retry(attempt_number, response,
File "/opt/python/botocore/retryhandler.py", line 277, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/opt/python/botocore/retryhandler.py", line 316, in __call__
checker_response = checker(attempt_number, response,
File "/opt/python/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(
File "/opt/python/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/opt/python/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/opt/python/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/opt/python/botocore/httpsession.py", line 287, in send
raise ConnectTimeoutError(endpoint_url=request.url, error=e) botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint
URL: "https://queue.amazonaws.com/" During handling of the above exception, another exception occurred: Traceback (most recent
call last):
File "/opt/python/botocore/retryhandler.py", line 269, in _should_retry
return self._checker(attempt_number, response, caught_exception)
File "/opt/python/botocore/retryhandler.py", line 316, in __call__
checker_response = checker(attempt_number, response,
File "/opt/python/botocore/retryhandler.py", line 222, in __call__
return self._check_caught_exception(
File "/opt/python/botocore/retryhandler.py", line 359, in _check_caught_exception
raise caught_exception
File "/opt/python/botocore/endpoint.py", line 200, in _do_get_response
http_response = self._send(request)
File "/opt/python/botocore/endpoint.py", line 269, in _send
return self.http_session.send(request)
File "/opt/python/botocore/httpsession.py", line 287, in send
raise ConnectTimeoutError(endpoint_url=request.url, error=e) botocore.exceptions.ConnectTimeoutError:
Connect timeout on endpoint URL: "https://queue.amazonaws.com/"
Based on the comments.
The SQS timeout was caused by the fact that the lambda function was associated with a VPC, and the VPC had no SQS VPC interface endpoint. Without the endpoint or NAT gateway, the function is not enable to connect to SQS.
The solution was to add the VPC interface endpoint for the SQS service.
I try to provide a custom object inside a rest api, created with flask_restful.
Object: Record
import json
class Record():
#CLASS RECORD
def __init__(self, DateTime, DateTimeText, Status, Icon, Temp):
#INITIALIZE
self.DateTime = DateTime
self.DateTimeText = DateTimeText
self.Status = Status
self.Icon = Icon
self.Temp = Temp
def __repr__(self):
return json.dumps(self, default=lambda o: o.__dict__, sort_keys=False, indent=4)
Result: print(record)
{
"DateTime": 1583949600,
"DateTimeText": "2020-03-11 18:00:00",
"Status": "Clouds",
"Icon": "04n",
"Temp": 280.57
}
Rest API:
from flask_restful import Resource, Api, reqparse
class _Weather(Resource):
#WEATHER
def get(self):
#GET WEATHER
return {'value': Weather.Record}
self.Api.add_resource(_Weather, '/api/weather')
Error:
all other calls works fine, only me custom object (http://localhost:80/api/weather) returns the following error stack:
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2463, in __call__
return self.wsgi_app(environ, start_response)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2449, in wsgi_app
response = self.handle_exception(e)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_restful\__init__.py", line 272, in error_router
return original_handler(e)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1866, in handle_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1951, in full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_restful\__init__.py", line 272, in error_router
return original_handler(e)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_cors\extension.py", line 161, in wrapped_function
return cors_after_request(app.make_response(f(*args, **kwargs)))
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1820, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\_compat.py", line 38, in reraise
raise value.with_traceback(tb)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1949, in full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask\app.py", line 1935, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_restful\__init__.py", line 472, in wrapper
return self.make_response(data, code, headers=headers)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_restful\__init__.py", line 501, in make_response
resp = self.representations[mediatype](data, *args, **kwargs)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\site-packages\flask_restful\representations\json.py", line 21, in output_json
dumped = dumps(data, **settings) + "\n"
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\__init__.py", line 234, in dumps
return cls(
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py", line 201, in encode
chunks = list(chunks)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py", line 431, in _iterencode
yield from _iterencode_dict(o, _current_indent_level)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py", line 405, in _iterencode_dict
yield from chunks
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py", line 438, in _iterencode
o = _default(o)
File "C:\Users\Martin\AppData\Local\Programs\Python\Python38-32\Lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Record is not JSON serializable
I try a lot of different approaches, found here on stack. Non of these works for my.
Python 3.8.2
You have a couple of options here.
Make a tojson() method for your Record class and call that for your return value. It will basically just return the underlying __dict__ for your object.
def tojson(self):
return self.__dict__
Pass Weather.Record.__dict__ directly as your return value
So your return statement will look like one of these:
return {'value': Weather.Record.__dict__}
Or, using jsonify from Flask:
return jsonify({'value': 'Weather.Record.__dict__})
Or replace Weather.Record.__dict__ with Weather.Record.tojson() if you add that method to the class.
I've been trying to test for a user that hasn't been verified.
class TestLoginApi(TestCase):
URL = '/rest-auth/login/'
EMAIL = 'testuser#test
PASSWORD = 'password'
DATA = {'email': EMAIL, 'password': PASSWORD}
#classmethod
def setUpTestData(cls):
cls.user = get_user_model().objects.create_user(username='testuser', email=cls.EMAIL,
password=cls.PASSWORD)
def test_login_api_without_verification(self):
response = self.client.post(self.URL, self.DATA, format='json')
The "response" line throws the following error
Error
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 59, in testPartExecutor
yield
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/unittest/case.py", line 601, in run
testMethod()
File "/Users/docdocengineering3/GitHub/website/project/authorization/Tests/test_login.py", line 34, in test_login_api_without_verification
response = self.client.post(self.URL, self.DATA, format='json')
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 548, in post
secure=secure, **extra)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 350, in post
secure=secure, **extra)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 416, in generic
return self.request(**r)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/test/client.py", line 501, in request
six.reraise(*exc_info)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/six.py", line 686, in reraise
raise value
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/views/decorators/debug.py", line 76, in sensitive_post_parameters_wrapper
return view(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.get(self, type(self))(*args2, **kwargs2)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/views.py", line 49, in dispatch
return super(LoginView, self).dispatch(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 489, in dispatch
response = self.handle_exception(exc)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 449, in handle_exception
self.raise_uncaught_exception(exc)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/views.py", line 486, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/views.py", line 92, in post
self.serializer.is_valid(raise_exception=True)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/serializers.py", line 237, in is_valid
self._validated_data = self.run_validation(self.initial_data)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_framework/serializers.py", line 435, in run_validation
value = self.validate(value)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/rest_auth/serializers.py", line 105, in validate
email_address = user.emailaddress_set.get(email=user.email)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/db/models/manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/Users/docdocengineering3/.virtualenvs/docdoc/lib/python3.6/site-packages/django/db/models/query.py", line 380, in get
self.model._meta.object_name
Exception: EmailAddress matching query does not exist.
I have no idea why this is happening. It isn't a setup problem as I've tried actually running the system, creating a user (not verifying) and when I "PostMan" the same link, I get the correct error back
{"non_field_errors": [ "E-mail is not verified." ] }
So it works in the actual product but not when testing. Anyone know why? Any help is greatly appreciated.
This is the only test that I can't get to work, all the rest runs correctly.
You probably have your setting EMAIL_VERIFICATION set to mandatory.
So you either change it to none in tests or manually create EmailAddress object (it's required by django-allauth when mandatory verification is on)
Im trying to get event from google calendar by python, Im using google quickstart example, I get browser opening to confirm credential but on my pc I get following error:
Traceback (most recent call last):
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 987, in _conn_request
conn.connect()
File "C:\Programs\Python\Python35-32\lib\http\client.py", line 1252, in connect
super().connect()
File "C:\Programs\Python\Python35-32\lib\http\client.py", line 849, in connect
(self.host,self.port), self.timeout, self.source_address)
File "C:\Programs\Python\Python35-32\lib\socket.py", line 693, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Programs\Python\Python35-32\lib\socket.py", line 732, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 79, in <module>
main()
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 60, in main
credentials = get_credentials()
File "C:\Users\myUser\Documents\Python_projects\quickstart.py", line 48, in get_credentials
credentials = tools.run_flow(flow, store, flags)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\tools.py", line 243, in run_flow
credential = flow.step2_exchange(code, http=http)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\util.py", line 137, in positional_wrapper
return wrapped(*args, **kwargs)
File "C:\Programs\Python\Python35-32\lib\site-packages\oauth2client\client.py", line 2027, in step2_exchange
headers=headers)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 1314, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 1064, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "C:\Programs\Python\Python35-32\lib\site-packages\httplib2\__init__.py", line 994, in _conn_request
raise ServerNotFoundError("Unable to find the server at %s" % conn.host)
httplib2.ServerNotFoundError: Unable to find the server at accounts.google.com
I suppose the problem is due to my proxy but where can I set proxy setting?
Thanks in advance