Note that there are some explanatory texts on larger screens.

plurals
  1. PONginx + Django + Admin + django-tinymce + fastcgi reports 500 - appears to be media pathing issue
    text
    copied!<p>Im getting 500 server errors with my fastcgi nginx setup and Django. The problem seems to be related to saving models / entries in the admin site. The problem appears to be that the paths on the redirect appear to be wrong and so django cant process them and it falls over. Here is my nginx config:</p> <pre><code>server { listen 80; rewrite ^/(.*) http://www.xxxxxx/$1 permanent; server_name sxxxxxxx; } server { listen 80; server_name www.xxxxx access_log /srv/www/sxxxxxx/logs/nginx_access.log; error_log /srv/www/sxxxxxxx/logs/nginx_error.log; location /media { root /srv/www/sxxxxx/public_html/section9/static/; } location / { root /srv/www/sxxxxxx/public_html/section9; fastcgi_pass unix:/tmp/section9.sock; #include fastcgi.conf; fastcgi_param PATH_INFO $fastcgi_script_name; fastcgi_param REQUEST_URI $request_uri; fastcgi_param SCRIPT_FILENAME $fastcgi_script_name; fastcgi_param REQUEST_METHOD $request_method; fastcgi_param CONTENT_TYPE $content_type; fastcgi_param CONTENT_LENGTH $content_length; fastcgi_param QUERY_STRING $query_string; fastcgi_param SERVER_ADDR $server_addr; fastcgi_param SERVER_PORT $server_port; fastcgi_param SERVER_NAME $server_name; fastcgi_param SERVER_PROTOCOL $server_protocol; fastcgi_param REQUEST_URI $request_uri; fastcgi_param DOCUMENT_URI $document_uri; fastcgi_param DOCUMENT_ROOT $document_root; fastcgi_param REMOTE_USER $remote_user; fastcgi_param REMOTE_ADDR $remote_addr; fastcgi_param REMOTE_PORT $remote_port; fastcgi_param SERVER_SOFTWARE "nginx"; fastcgi_param GATEWAY_INTERFACE "CGI/1.1"; fastcgi_param UID_SET $uid_set; fastcgi_param UID_GOT $uid_got; fastcgi_pass_header Authorization; fastcgi_intercept_errors off; } } </code></pre> <p>And here is the error message:</p> <pre><code>Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/pymodules/python2.6/django/contrib/admin/options.py", line 252, in wrapper return self.admin_site.admin_view(view)(*args, **kwargs) File "/usr/lib/pymodules/python2.6/django/views/decorators/cache.py", line 44, in _wrapped_view_func response = view_func(request, *args, **kwargs) File "/usr/lib/pymodules/python2.6/django/contrib/admin/sites.py", line 186, in inner return view(request, *args, **kwargs) File "/usr/lib/pymodules/python2.6/django/db/transaction.py", line 240, in _commit_on_success res = func(*args, **kw) File "/usr/lib/pymodules/python2.6/django/contrib/admin/options.py", line 819, in change_view obj = self.queryset(request).get(pk=unquote(object_id)) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 299, in get clone = self.filter(*args, **kwargs) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 498, in filter return self._filter_or_exclude(False, *args, **kwargs) File "/usr/lib/pymodules/python2.6/django/db/models/query.py", line 516, in _filter_or_exclude clone.query.add_q(Q(*args, **kwargs)) File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1675, in add_q can_reuse=used_aliases) File "/usr/lib/pymodules/python2.6/django/db/models/sql/query.py", line 1614, in add_filter connector) File "/usr/lib/pymodules/python2.6/django/db/models/sql/where.py", line 56, in add obj, params = obj.process(lookup_type, value) File "/usr/lib/pymodules/python2.6/django/db/models/sql/where.py", line 269, in process params = self.field.get_db_prep_lookup(lookup_type, value) File "/usr/lib/pymodules/python2.6/django/db/models/fields/__init__.py", line 210, in get_db_prep_lookup return [self.get_db_prep_value(value)] File "/usr/lib/pymodules/python2.6/django/db/models/fields/__init__.py", line 361, in get_db_prep_value return int(value) ValueError: invalid literal for int() with base 10: '31/favicon.ico' &lt;WSGIRequest GET:&lt;QueryDict: {}&gt;, POST:&lt;QueryDict: {}&gt;, META:{'CONTENT_LENGTH': '', 'CONTENT_TYPE': '', 'HTTP_ACCEPT': '*/*', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.3', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate,sdch', 'HTTP_ACCEPT_LANGUAGE': 'en-US,en;q=0.8', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_HOST': 'www.xxxxx', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.220 Safari/535.1', 'PATH_INFO': u'/admin/portfolio/portfolioentry/31/favicon.ico/', 'QUERY_STRING': '', 'REQUEST_METHOD': 'GET', 'SCRIPT_NAME': u'', 'SERVER_NAME': 'localhost', 'SERVER_PORT': '80', 'SERVER_PROTOCOL': 'HTTP/1.0', 'wsgi.errors': &lt;flup.server.fcgi_base.TeeOutputStream object at 0xa779e6c&gt;, 'wsgi.input': &lt;flup.server.fcgi_base.InputStream object at 0xa779c6c&gt;, - Hide quoted text - 'wsgi.multiprocess': True, 'wsgi.multithread': False, 'wsgi.run_once': False, 'wsgi.url_scheme': 'http', 'wsgi.version': (1, 0)}&gt; </code></pre> <p>So it seems that I'm getting issues with the media. All the JS and CSS seem to be appended to the existing URL which suggests that the {{MEDIA_URL}} or whatever directive the admin site uses isnt working in this rather odd case.</p> <p>I would point out that this appears to occur on the model that has the tinymce plugin and not the others o the same site</p> <p>'PATH_INFO': u'/admin/portfolio/portfolioentry/31/favicon.ico/',</p> <p>Clearly the above is wrong. Im not sure why this has occured recently. Possibly due to an upgrade or similar.</p> <p>Would appreciate any other suggestions. I was thinking maybe something do to with referrer but probably not.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload