Why is my Django DRF RequestsClient request failing in tests? - python

I have a few Django Rest Framework API endpoints I want to test.
They are behind an authenticated page. I'm trying to use the DRF RequestsClient to do that.
My code looks like this:
from rest_framework.test import APITestCase
from rest_framework.test import RequestsClient
from django.urls import reverse
import requests
URL_PREFIX="http://testserver"
API_TOKEN="tfhgffhgf675h"
class APITests(APITestCase):
#staticmethod
def _get_full_url(url, *args, **kwargs):
return URL_PREFIX + reverse(url, *args, **kwargs)
def setUp(self):
self.client = RequestsClient()
def test_stuff(self):
url = self._get_full_url("ahs:agena_results-list")
# Raw requests library - works fine
# Note: Testing shows that the RequestsClient() seems to do some sort of magic to
# be able to resolve http://testserver. A raw requests GET request must hit it at
# 127.0.0.1, and specify the port
response = requests.get("http://127.0.0.1:8000", headers={"Authorization": f"Token {API_TOKEN}"})
# RequestsClient() - doesn't work
response = self.client.get(url, headers={"Authorization": f"Token {API_TOKEN}"})
My RequestsClient request doesn't work, but my raw requests request works fine.
The exception raised when using the RequestsClient is pretty cryptic:
Internal Server Error: /ahs/api/agena_results/
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1361, in execute_sql
cursor.execute(sql, params)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 67, in execute
return self._execute_with_wrappers(
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/usr/local/lib/python3.9/site-packages/django/db/backends/utils.py", line 83, in _execute
self.db.validate_no_broken_transaction()
File "/usr/local/lib/python3.9/site-packages/django/db/backends/base/base.py", line 480, in validate_no_broken_transaction
raise TransactionManagementError(
django.db.transaction.TransactionManagementError: An error occurred in the current transaction. You can't execute queries until the end of the 'atomic' block.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 497, in dispatch
self.initial(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 414, in initial
self.perform_authentication(request)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 324, in perform_authentication
request.user
File "/usr/local/lib/python3.9/site-packages/rest_framework/request.py", line 227, in user
self._authenticate()
File "/usr/local/lib/python3.9/site-packages/rest_framework/request.py", line 380, in _authenticate
user_auth_tuple = authenticator.authenticate(self)
File "/usr/local/lib/python3.9/site-packages/rest_framework/authentication.py", line 196, in authenticate
return self.authenticate_credentials(token)
File "/usr/local/lib/python3.9/site-packages/rest_framework/authentication.py", line 201, in authenticate_credentials
token = model.objects.select_related('user').get(key=key)
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 492, in get
num = len(clone)
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 302, in __len__
self._fetch_all()
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 1507, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/local/lib/python3.9/site-packages/django/db/models/query.py", line 57, in __iter__
results = compiler.execute_sql(
File "/usr/local/lib/python3.9/site-packages/django/db/models/sql/compiler.py", line 1364, in execute_sql
cursor.close()
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 83, in close
while self.nextset():
File "/usr/local/lib/python3.9/site-packages/MySQLdb/cursors.py", line 137, in nextset
nr = db.next_result()
MySQLdb._exceptions.OperationalError: (2006, '')
.
----------------------------------------------------------------------
Ran 1 test in 30.774s
The strange thing is that if I remove the Authorization header from the RequestsClient request, it doesn't crash, but does return a 403, so that doesn't help me.
I also tried setting the Authorization header on the RequestsClient this way, but that didn't help either:
self.client.headers.update({'Authorization': f'Token {API_TOKEN}'})
Any idea what I'm doing wrong?

Using APILiveServerTestCase instead of APITestCase when using RequestsClient solves the problem.
Apparently, the poor documentation around this has been known for some time now, but does not appear to have improved since then.

Related

geopy.exc.GeocoderServiceError: Non-successful status code 502

I use geopy to convet a coordinate into an address in order to get the name of the country and this is my code :
def convert_latandlong_to_address(self):
geolocator = Nominatim(user_agent="miz")
location = geolocator.reverse(self.lat+","+self.lng,timeout=10)
address = location.raw['address']
return address
it works fine but i realized that after several requests it returns 502 error :
geopy.exc.GeocoderServiceError: Non-successful status code 502
and this is full traceback:
Traceback (most recent call last):
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/geocoders/base.py", line 360, in _call_geocoder
result = self.adapter.get_json(url, timeout=timeout, headers=req_headers)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/adapters.py", line 373, in get_json
resp = self._request(url, timeout=timeout, headers=headers)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/adapters.py", line 401, in _request
raise AdapterHTTPError(
geopy.adapters.AdapterHTTPError: Non-successful status code 502
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/rest_framework/decorators.py", line 50, in handler
return func(*args, **kwargs)
File "/home/admin1/mizbanproject/location/preferlocation/api/views.py", line 15, in get_prefer_locations
address = location_obj.convert_latandlong_to_address()
File "/home/admin1/mizbanproject/location/preferlocation/api/utils.py", line 27, in convert_latandlong_to_address
location = geolocator.reverse(self.lat+","+self.lng,timeout=10)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/geocoders/nominatim.py", line 359, in reverse
return self._call_geocoder(url, callback, timeout=timeout)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/geocoders/base.py", line 378, in _call_geocoder
self._adapter_error_handler(error)
File "/home/admin1/envs/myvenv/lib/python3.8/site-packages/geopy/geocoders/base.py", line 392, in _adapter_error_handler
raise exc_cls(str(error)) from error
geopy.exc.GeocoderServiceError: Non-successful status code 502
and after a few seconds or minutes when i run the code again it works i can't figure out what causes this problem and how can i prevent it ?

TypeError: __str__ returned non-string (type NoneType) With Django third party package Models

I installed the django_message package into my django app using django 2.0 and while it works on my development machine, it throws the following errors on production when I try to open the list of messages from Django Admin console.
TypeError: __str__ returned non-string (type NoneType)
[22/Mar/2019 15:08:12] ERROR [django.request:118] Internal Server Error: /admin/django_messages/message/
Traceback (most recent call last):
File "/opt/site_env/lib/python3.6/site-packages/django/core/handlers/exception.py", line 35, in inner
response = get_response(request)
File "/opt/site_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 128, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/opt/site_env/lib/python3.6/site-packages/django/core/handlers/base.py", line 126, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 574, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/sites.py", line 223, in inner
return view(request, *args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/utils/decorators.py", line 62, in _wrapper
return bound_func(*args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/opt/site_env/lib/python3.6/site-packages/django/utils/decorators.py", line 58, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 1570, in changelist_view
cl = self.get_changelist_instance(request)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/options.py", line 705, in get_changelist_instance
self,
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/views/main.py", line 76, in __init__
self.queryset = self.get_queryset(request)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/views/main.py", line 320, in get_queryset
filters_use_distinct) = self.get_filters(request)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/views/main.py", line 130, in get_filters
self.model, self.model_admin, field_path=field_path
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/filters.py", line 157, in create
return list_filter_class(field, request, params, model, model_admin, field_path=field_path)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/filters.py", line 168, in __init__
self.lookup_choices = self.field_choices(field, request, model_admin)
File "/opt/site_env/lib/python3.6/site-packages/django/contrib/admin/filters.py", line 195, in field_choices
return field.get_choices(include_blank=False)
File "/opt/site_env/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 812, in get_choices
limit_choices_to)]
File "/opt/site_env/lib/python3.6/site-packages/django/db/models/fields/__init__.py", line 811, in <listcomp>
for x in rel_model._default_manager.complex_filter(
File "/opt/site_env/lib/python3.6/site-packages/django/utils/encoding.py", line 34, in smart_text
return force_text(s, encoding, strings_only, errors)
File "/opt/site_env/lib/python3.6/site-packages/django/utils/encoding.py", line 67, in force_text
s = str(s)
TypeError: __str__ returned non-string (type NoneType)
The biggest concern is that this is not the only model that is throwing the error. I have the same from django-allauth throwing the same error with SocialAccount.
Another concern is that I don't think I should be fixing the codes from this packages but I am left with nothing else.
Also to note, that none of the models for the application itself causes these error.
Only applies to django_allauth and django_messages. However, the failure doesn't happen in my development machine.
The mysql table for django_messages is empty (without records).
Is there a config that causes these kinds of errors or somethings.
I am using django 2.0 and python 3.6 in both enviroments.
Figured out.
It turns out that all the models failing are related to the User model whose str() method points to a field that has its database column as NULLs.
Solution: I have to make that field not nullable at the database level and at django level by assigning default value at the pre_save phase.
It worked.

ValueError in py2neo graph query

I'm trying to do a simple graph query in neo4j from python. My query looks like
def do_query(self):
graph = Graph(settings.NEO4J_CONNECTION_STRING)
query = 'MATCH (n:SomeNode) WHERE n.id = ' + id + ' RETURN n'
data = graph.cypher.execute(query)
but when I run it in a Django REST handler, I get the following error
Traceback (most recent call last):
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/rest_framework/views.py", line 466, in dispatch
response = self.handle_exception(exc)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/rest_framework/views.py", line 463, in dispatch
response = handler(request, *args, **kwargs)
File "/Users/me/Development/app/search/api/views.py", line 351, in get
results = graph_queries.do_query(user_id)
File "/Users/me/Development/app/app/graph_queries.py", line 43, in do_query
data = graph.cypher.execute(query)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/core.py", line 661, in cypher
metadata = self.resource.metadata
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/core.py", line 213, in metadata
self.get()
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/core.py", line 258, in get
response = self.__base.get(headers=headers, redirect_limit=redirect_limit, **kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 966, in get
return self.__get_or_head("GET", if_modified_since, headers, redirect_limit, **kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 943, in __get_or_head
return rq.submit(redirect_limit=redirect_limit, **kwargs)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 433, in submit
http, rs = submit(self.method, uri, self.body, self.headers)
File "/Users/me/.virtualenvs/app/lib/python2.7/site-packages/py2neo/packages/httpstream/http.py", line 302, in submit
raise ValueError("Unsupported URI scheme " + repr(uri.scheme))
ValueError: Unsupported URI scheme None
I'm not really sure where to begin. I'm pretty confident the connection to Neo4J is good, and the handler is being invoked correctly as shown in the traceback. Is there something wrong with my query?
Turns out the problem was I was using import settings rather than from django.conf import settings, which meant I wasn't reading the correct setting.

jinja2 TemplateNotFound if my library installed via pip

The following code is in a library
self.env = Environment(loader=PackageLoader('netjsonconfig.backends.openwrt', 'templates'),
trim_blocks=True)
The library is used by a consumer app, if the library is installed via python setup.py develop the consumer app works correctly while if the library is installed via pip the consumer app crashes with the following traceback (see failing build on travis):
Traceback (most recent call last):
File "/home/travis/build/openwisp/django-netjsonconfig/django_netjsonconfig/tests/test_device_admin.py", line 33, in test_download_config
response = self.client.get(path)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/test/client.py", line 503, in get
**extra)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/test/client.py", line 304, in get
return self.generic('GET', path, secure=secure, **r)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/test/client.py", line 380, in generic
return self.request(**r)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/test/client.py", line 467, in request
six.reraise(*exc_info)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/utils/six.py", line 686, in reraise
raise value
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/utils/decorators.py", line 149, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 244, in inner
return view(request, *args, **kwargs)
File "/home/travis/build/openwisp/django-netjsonconfig/django_netjsonconfig/admin.py", line 52, in download_view
device.backend_instance.generate(device.name)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/netjsonconfig-0.3.1-py3.4.egg/netjsonconfig/backends/openwrt/openwrt.py", line 104, in generate
uci = self.render()
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/netjsonconfig-0.3.1-py3.4.egg/netjsonconfig/backends/openwrt/openwrt.py", line 77, in render
additional_output = renderer.render()
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/netjsonconfig-0.3.1-py3.4.egg/netjsonconfig/backends/base.py", line 41, in render
template = self.env.get_template(template_name)
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/environment.py", line 812, in get_template
return self._load_template(name, self.make_globals(globals))
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/environment.py", line 774, in _load_template
cache_key = self.loader.get_source(self, name)[1]
File "/home/travis/virtualenv/python3.4.2/lib/python3.4/site-packages/Jinja2-2.8-py3.4.egg/jinja2/loaders.py", line 235, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: system.uci
It seems that it's looking templates in ./templates and it obviously doesn't work. I think I've not understood TemplateLoaders in Jinja very well. What am I doing wrong?
When you pip install netjsonconfig it does not include a templates folder along side the python code. Looks like a setup.py issue.
(venv)Josh:netjsonconfig$ find .
.
./__init__.py
./backends
./backends/__init__.py
./backends/base.py
./backends/openwisp
./backends/openwisp/__init__.py
./backends/openwisp/openwisp.py
./backends/openwisp/schema.py
./backends/openwrt
./backends/openwrt/__init__.py
./backends/openwrt/openwrt.py
./backends/openwrt/renderers.py
./backends/openwrt/schema.py
./backends/openwrt/timezones.py
./exceptions.py
./schema.py
./utils.py
./version.py

python oauthlib: in escape ValueError "Only unicode objects are escapable"

I'm using python-social-auth to login with social networks from my Django application. On my local machine everything works fine, but when I deploy to a server I get the following error:
oauthlib.oauth1.rfc5849.utils in escape
ValueError: Only unicode objects are escapable. Got None of type <type 'NoneType'>.
Stacktrace:
File "django/core/handlers/base.py", line 112, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "social/apps/django_app/utils.py", line 45, in wrapper
return func(request, backend, *args, **kwargs)
File "social/apps/django_app/views.py", line 12, in auth
return do_auth(request.social_strategy, redirect_name=REDIRECT_FIELD_NAME)
File "social/actions.py", line 25, in do_auth
return strategy.start()
File "social/strategies/base.py", line 66, in start
return self.redirect(self.backend.auth_url())
File "social/backends/oauth.py", line 99, in auth_url
token = self.set_unauthorized_token()
File "social/backends/oauth.py", line 158, in set_unauthorized_token
token = self.unauthorized_token()
File "social/backends/oauth.py", line 177, in unauthorized_token
method=self.REQUEST_TOKEN_METHOD)
File "social/backends/base.py", line 202, in request
response = request(method, url, *args, **kwargs)
File "requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "requests/sessions.py", line 349, in request
prep = self.prepare_request(req)
File "requests/sessions.py", line 287, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "requests/models.py", line 291, in prepare
self.prepare_auth(auth, url)
File "requests/models.py", line 470, in prepare_auth
r = auth(self)
File "requests_oauthlib/oauth1_auth.py", line 87, in __call__
unicode(r.url), unicode(r.method), None, r.headers)
File "oauthlib/oauth1/rfc5849/__init__.py", line 293, in sign
request.oauth_params.append(('oauth_signature', self.get_oauth_signature(request)))
File "oauthlib/oauth1/rfc5849/__init__.py", line 128, in get_oauth_signature
uri, headers, body = self._render(request)
File "oauthlib/oauth1/rfc5849/__init__.py", line 199, in _render
headers = parameters.prepare_headers(request.oauth_params, request.headers, realm=realm)
File "oauthlib/oauth1/rfc5849/utils.py", line 31, in wrapper
return target(params, *args, **kwargs)
File "oauthlib/oauth1/rfc5849/parameters.py", line 57, in prepare_headers
escaped_value = utils.escape(value)
File "oauthlib/oauth1/rfc5849/utilsy", line 56, in escape
'Got %s of type %s.' % (u, type(u)))
Some packages from requirements.txt file:
Django==1.6.6
google-api-python-client==1.1
oauth2==1.5.211
oauthlib==0.6.3
python-openid==2.2.5
python-social-auth==0.1.26
requests==2.4.0
requests-oauthlib==0.4.1
six==1.7.3
I got this error when I did not provide my OAuth Consumer key and secrets in my django settings file. It's essentially a "Required setting not found" error. Is it worth checking all your settings copied across successfully when you deployed?
I've upgraded to python-social-auth and had the same problem with Linkedin login. Parameter names in settings are changed in the latest version so instead:
LINKEDIN_CONSUMER_KEY and LINKEDIN_CONSUMER_SECRET it'd be used: SOCIAL_AUTH_LINKEDIN_KEY and SOCIAL_AUTH_LINKEDIN_SECRET.
the problem comes to you if this statement have spelling mistake:
tweepy.OAuthHandler(consumer_key,consumer_secret)

Categories