import os
import sys
from django.core.wsgi import get_wsgi_application
import socketio
sio = socketio.Client()
print('Created socketio client')
#sio.event
def connect():
print('connected to server')
#sio.event
def disconnect():
print('disconnected from server')
sio.connect('http://localhost:8000/socket.io/')
sio.wait()
app_path = os.path.abspath(os.path.join(
os.path.dirname(os.path.abspath(__file__)), os.pardir))
sys.path.append(os.path.join(app_path, 'myapp'))
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
application = get_wsgi_application()
if os.environ.get('DJANGO_SETTINGS_MODULE') == 'config.settings.production':
application = application
Here is my wsgi.py file, I am not sure whether to use it here or not. When I start the server it throws
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\socketio\client.py", line 246, in connect
six.raise_from(exceptions.ConnectionError(exc.args[0]), None)
File "<string>", line 3, in raise_from
socketio.exceptions.ConnectionError: Connection refused by the server
Am I missing out something else?
UPDATE 1
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x000001E926004C18>
Traceback (most recent call last):
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 140, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\contrib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super().get_handler(*args, **options)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\commands\runserver.py", line 65, in get_handler
return get_internal_wsgi_application()
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\servers\basehttp.py", line 44, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\module_loading.py", line 17, in import_string
module = import_module(module_path)
File "C:\Users\prabh\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 "D:\Programming\python\myapp\config\wsgi.py", line 34, in <module>
sio.connect('http://localhost:8000/socket.io/')
File "C:\Users\prabh\AppData\Local\Programs\Python\Python37\lib\site-packages\socketio\client.py", line 246, in connect
six.raise_from(exceptions.ConnectionError(exc.args[0]), None)
File "<string>", line 3, in raise_from
UPDATE 2
socket.on('connect', function() {
console.log('CONNECTED');
socket.emit('on message', 'data');
});
Related
I am using Elasticsearch APM in Python to log requests for a FastAPI app.
There is a mechanism to load custom processors by simply specifying the module path to the custom processor function.
My app layout is as follows:
app
├── __init__.py
├── apm_processors.py
├── main.py
└── version.py
My apm_processors.py file has the following function defined:
def ip_processor(client, event):
# process the event
pass
So, in my app, I do:
# other imports
from elasticapm.contrib.starlette import make_apm_client, ElasticAPM
from . import apm_processors
And to set up APM, I call:
apm_config = {
"SERVICE_NAME": config('ELASTIC_APM_SERVICE_NAME', cast=str, default="Server"),
"SECRET_TOKEN": str(config('ELASTIC_APM_SECRET_TOKEN', cast=Secret, default="")),
"SERVER_URL": config('ELASTIC_APM_SERVER_URL', cast=str, default="http://localhost:8200"),
"PROCESSORS": (
"elasticapm.processors.sanitize_http_request_cookies",
"elasticapm.processors.sanitize_http_headers",
"apm_processors.ip_processor"
)
}
apm = make_apm_client(apm_config)
app = FastAPI()
# other app setup
app.add_middleware(ElasticAPM, client=apm)
This throws an error:
ModuleNotFoundError: No module named 'apm_processors'
With the following stacktrace:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/uvicorn/subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 60, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/local/lib/python3.9/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/lib/python3.9/asyncio/base_events.py", line 647, in run_until_complete
return future.result()
File "/usr/local/lib/python3.9/site-packages/uvicorn/server.py", line 67, in serve
config.load()
File "/usr/local/lib/python3.9/site-packages/uvicorn/config.py", line 458, in load
self.loaded_app = import_from_string(self.app)
File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 24, in import_from_string
raise exc from None
File "/usr/local/lib/python3.9/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/statisticsserver/./app/main.py", line 75, in <module>
apm = make_apm_client(apm_config)
File "/usr/local/lib/python3.9/site-packages/elasticapm/contrib/starlette/__init__.py", line 70, in make_apm_client
return client_cls(config, **defaults)
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 153, in __init__
"processors": self.load_processors(),
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 640, in load_processors
return [seen.setdefault(path, import_string(path)) for path in processors if path not in seen]
File "/usr/local/lib/python3.9/site-packages/elasticapm/base.py", line 640, in <listcomp>
return [seen.setdefault(path, import_string(path)) for path in processors if path not in seen]
File "/usr/local/lib/python3.9/site-packages/elasticapm/utils/module_import.py", line 47, in import_string
module = import_module(module_path)
File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'apm_processors'
As far as I can tell it uses import_module to import the function as specified, but for some reason it claims there is no such module — although I am actually able to import it.
How can I specify the processor?
Since the context/main module of the application is app, the import should be done as follows:
"PROCESSORS": (
"elasticapm.processors.sanitize_http_request_cookies",
"elasticapm.processors.sanitize_http_headers",
"app.apm_processors.ip_processor"
)
This way, the import succeeds and the function will be called for each event.
I am trying to run a project About sdn mininet&ryu controller. source: https://github.com/archanas23/SDN-Project but when I try to run a dumper file step 3, I get this error.
Command:
PYTHONPATH=. ./bin/ryu-manager --verbose --observe-links ryu/topology/dumper.py ./ryu/controller/controller.py
Error:
loading app ./ryu/controller/controller.py
Traceback (most recent call last):
File "./bin/ryu-manager", line 19, in <module>
main()
File "/home/saber/ryu/ryu/cmd/manager.py", line 98, in main
app_mgr.load_apps(app_lists)
File "/home/saber/ryu/ryu/base/app_manager.py", line 415, in load_apps
cls = self.load_app(app_cls_name)
File "/home/saber/ryu/ryu/base/app_manager.py", line 392, in load_app
mod = utils.import_module(name)
File "/home/saber/ryu/ryu/utils.py", line 99, in import_module
return _import_module_file(modname)
File "/home/saber/ryu/ryu/utils.py", line 88, in _import_module_file
return load_source(modname, abspath)
File "/home/saber/ryu/ryu/utils.py", line 42, in load_source
return loader.load_module(name)
File "<frozen importlib._bootstrap_external>", line 522, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 1027, in load_module
File "<frozen importlib._bootstrap_external>", line 852, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/saber/ryu/ryu/controller/controller.py", line 58, in <module>
CONF.register_cli_opts([
File "/home/saber/.local/lib/python3.8/site-packages/oslo_config/cfg.py", line 2077, in __inner
result = f(self, *args, **kwargs)
File "/home/saber/.local/lib/python3.8/site-packages/oslo_config/cfg.py", line 2363, in register_cli_opts
self.register_cli_opt(opt, group, clear_cache=False)
File "/home/saber/.local/lib/python3.8/site-packages/oslo_config/cfg.py", line 2081, in __inner
return f(self, *args, **kwargs)
File "/home/saber/.local/lib/python3.8/site-packages/oslo_config/cfg.py", line 2355, in register_cli_opt
raise ArgsAlreadyParsedError("cannot register CLI option")
oslo_config.cfg.ArgsAlreadyParsedError: arguments already parsed: cannot register CLI option
I'm facing this issue when I run this command and it creates a makecpython.py:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
ext_modules = [Extension("cloneNodes", ["app/v3/impl/cloneNodes.pyx"])]
setup(
name = 'arr',
cmdclass = {'build_ext': build_ext},
ext_modules = ext_modules,
compiler_directives={'language_level' : "3"}
)
Later I run my file to clone the nodes to this is created, this is the clonenode.py file made:
from cpython cimport *
def cloningNodes(matrix,toClone):
cdef Py_ssize_t matrixSize=PyList_Size(matrix),cloneSize=PyList_Size(toClone),newSize=matrixSize+cloneSize,i,j
output=PyList_New(newSize)
for i in range(matrixSize):
currentMatrixRow=<object>PyList_GET_ITEM(matrix,i)
Py_INCREF(currentMatrixRow)
PyList_SET_ITEM(output,i,
currentMatrixRow)
for j in range(cloneSize):
currentRow=<object>PyList_GET_ITEM(output,i)
PyList_Append(currentRow,<object>PyList_GET_ITEM(
<object>PyList_GET_ITEM(matrix,i),PyLong_AsSsize_t(<object>PyList_GET_ITEM(toClone,j))
)
)
for i in range(cloneSize):
toCloneRow=<object>PyList_GET_ITEM(output,PyLong_AsSsize_t(<object>PyList_GET_ITEM(toClone,i)))
Py_INCREF(toCloneRow)
PyList_SET_ITEM(output,i+matrixSize,toCloneRow)
return output
Now I have to run the uvicorn main app thus instead of showing the link it goes to the dll error:
uvicorn main:app
Traceback (most recent call last):
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\nkgad\AppData\Local\Programs\Python\Python39\Scripts\uvicorn.exe\__main__.py", line 7, in <module>
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1128, in __call__
return self.main(*args, **kwargs)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1053, in main
rv = self.invoke(ctx)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 1395, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\click\core.py", line 754, in invoke
return __callback(*args, **kwargs)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\main.py", line 425, in main
run(app, **kwargs)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\main.py", line 447, in run
server.run()
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\server.py", line 68, in run
return asyncio.run(self.serve(sockets=sockets))
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\asyncio\base_events.py", line 642, in run_until_complete
return future.result()
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\server.py", line 76, in serve
config.load()
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\config.py", line 448, in load
self.loaded_app = import_from_string(self.app)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\importer.py", line 24, in import_from_string
raise exc from None
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "c:\users\nkgad\appdata\local\programs\python\python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File ".\main.py", line 3, in <module>
from app.api import app
File ".\app\api.py", line 4, in <module>
from .v3.controller.route_info_controller import RouteController
File ".\app\v3\controller\route_info_controller.py", line 2, in <module>
from ..impl.vrp_impl import VRPImpl
File ".\app\v3\impl\vrp_impl.py", line 6, in <module>
from .open_route_map_impl import OpenRouteImpl
File ".\app\v3\impl\open_route_map_impl.py", line 2, in <module>
from cloneNodes import cloningNodes
ImportError: DLL load failed while importing cloneNodes: The parameter is incorrect.
How can I resolve this DLL load failure issue?
I want to get cryptocurrency data from external websocket and save it to database. In order to run producer.py from start, I added it to INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
'crypto.spot.producer',
]
producer.py is:
from .models import Spot
async def message(u, t, interval, timeout):
async with websockets.connect(uri=u + '?token=' + t, ping_interval=interval, ping_timeout=timeout) as websocket:
await websocket.send(json.dumps({"id": "4848226",
"type": "subscribe",
"topic": "/market/ticker:all",
"response": True}))
while True:
response = await websocket.recv()
result = json.loads(response)
'''
write result to django model (Spot)
'''
while True:
response = r.post('https://api.kucoin.com/api/v1/bullet-public')
payload = json.loads(response.text)
uri = payload['data']['instanceServers'][0]['endpoint']
token = payload['data']['token']
ping_interval = payload['data']['instanceServers'][0]['pingInterval']
ping_timeout = payload['data']['instanceServers'][0]['pingTimeout']
asyncio.get_event_loop().run_until_complete(message(uri, token, ping_interval, ping_timeout))
asyncio.get_event_loop().run_forever()
However, I get the following error:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\a.daghestani\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\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\a.daghestani\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\a.daghestani\Desktop\marlikfund\crypto\spot\producer.py", line 9, in <module>
from .models import Spot
File "C:\Users\a.daghestani\Desktop\marlikfund\crypto\spot\models.py", line 6, in <module>
class Spot(models.Model):
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\db\models\base.py", line 107, in __new__
app_config = apps.get_containing_app_config(module)
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 252, in get_containing_app_config
self.check_apps_ready()
File "C:\Users\a.daghestani\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", line 135, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
any idea?
You getting this error because you can not access models before django loading is finished. Your module tries to access models while they are not loaded yet.
To solve your problem you should create a django management command or an standalone script which loads and configures django, after that you can run your producer loop and access models without any problem. e.g.
producer.py modeuls:
import sys, os, django
sys.path.append("/path/to/your/project")
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "your-project.settings")
django.setup()
from <your-app>.models import Spot
.... Your script
Don't forget to remove the module (crypto.spot.producer) from INSTALLED_APPS.
I'm currently working on a project that uses Twilio to have an automated survey. I'm trying python manage.py runserver and I get the following results:
System check identified no issues (0 silenced).
April 23, 2017 - 12:15:51
Django version 1.11, using settings 'vizeserver.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x04406FA8
>
Traceback (most recent call last):
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\uti
ls\autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\management\commands\runserver.py", line 147, in inner_run
handler = self.get_handler(*args, **options)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\con
trib\staticfiles\management\commands\runserver.py", line 27, in get_handler
handler = super(Command, self).get_handler(*args, **options)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\management\commands\runserver.py", line 68, in get_handler
return get_internal_wsgi_application()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\servers\basehttp.py", line 47, in get_internal_wsgi_application
return import_string(app_path)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\uti
ls\module_loading.py", line 20, in import_string
module = import_module(module_path)
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py",
line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "C:\Users\Thomas\Documents\Development\TwilioSurvey\vizeserver\vizeserver\wsgi.py", lin
e 16, in <module>
application = get_wsgi_application()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\cor
e\wsgi.py", line 14, in get_wsgi_application
return WSGIHandler()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\wsgi.py", line 151, in __init__
self.load_middleware()
File "C:\Users\Thomas\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\handlers\base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: object() takes no parameters
I have looked into my vizeserver.settings and I don't see anything off.
The link for the github is https://github.com/Vize-Programming-Team/web-server. I've been trying to see if there is anything wrong with the middleware but I don't know what's wrong.
Thanks!
The problem is with your middleware, try changing your middleware.py in auto_survey to
class SMSMiddleware(object):
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
args = request.POST or request.GET
request.is_sms = args and args.get('MessageSid')
return response