Djano CMS + uWSGI + virtualenv + socket causing PendingDeprecationWarning error in uWSGI logs
Question: Here's the error:

    
    
    Traceback (most recent call last):
      File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
        self.load_middleware()
      File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 45, in load_middleware
        mw_class = import_by_path(middleware_path)
      File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/module_loading.py", line 21, in import_by_path
        module = import_module(module_path)
      File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
        __import__(name)
      File "/var/apps/tango/envs/tango-env/local/lib/python2.7/site-packages/django/middleware/doc.py", line 4, in <module>
        warnings.warn(__doc__, PendingDeprecationWarning, stacklevel=2)
    TypeError: expected string or buffer
    

**TypeError: expected string or buffer**

Tango is the user I created specifically for this project.

I'm using upstart so in /etc/init/tango-wsgi.conf looks like:

    
    
    exec /var/apps/tango/envs/tango-env/bin/uwsgi \
    --uid tango \
    --home /var/apps/tango/envs/tango-env \
    --pythonpath /var/apps/tango/tango/src \
    --wsgi-file /var/apps/tango/tango/src/tango_cms/wsgi.py \
    --socket /tmp/tango-uwsgi.sock \
    --chmod-socket \
    --logdate \
    --optimize 2 \
    --processes 2 \
    --master \
    --logto /var/apps/tango/logs/uwsgi.log
    

**UPDATE:**

My nginx.conf has following entry:

    
    
    location / {
            uwsgi_pass unix:/tmp/tango-uwsgi.sock;  
            include /etc/nginx/uwsgi_params;
    }
    

Please help.


Answer: Same problem here. I fixed it deleting the following line on `tango-wsgi.conf`
file:

`--optimize 2 \`

Optimize allows some kind of python optimization: [More
info](http://stackoverflow.com/questions/4777113/what-does-python-
optimization-o-or-pythonoptimize-do)

