Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango: RequestContext issues?
    primarykey
    data
    text
    <p>I'm new to Django and Python.</p> <p>When I move my code from my local dev box to my site on Webfaction it seems to break my code. If I then remove (<strong>context_instance=RequestContext(request)</strong>) from my main application views.py it seems to fix the problem. If later I put the line back in it works fine. </p> <pre><code>return render_to_response('template.html', {"var": var},**context_instance=RequestContext(request)**) </code></pre> <p>Error email from webhost:</p> <pre><code>Traceback (most recent call last): File "/home/hhadmin69/webapps/django/lib/python2.5/django/core/handlers/base.py", line 92, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/home/hhadmin69/webapps/django/hhv3/article/views.py", line 32, in post_index return render_to_response('article/post_index.html', {"posts": posts},context_instance=RequestContext(request)) File "/home/hhadmin69/webapps/django/lib/python2.5/django/template/context.py", line 107, in __init__ self.update(processor(request)) File "/home/hhadmin69/webapps/django/hhv3/context_processors.py", line 12, in latest_tweet tweet = twitter.Api().GetUserTimeline( settings.TWITTER_USER )[0] File "build\bdist.win32\egg\twitter.py", line 1414, in GetUserTimeline File "build\bdist.win32\egg\twitter.py", line 2032, in _FetchUrl File "/usr/local/lib/python2.5/urllib2.py", line 387, in open response = meth(req, response) File "/usr/local/lib/python2.5/urllib2.py", line 498, in http_response 'http', request, response, code, msg, hdrs) File "/usr/local/lib/python2.5/urllib2.py", line 425, in error return self._call_chain(*args) File "/usr/local/lib/python2.5/urllib2.py", line 360, in _call_chain result = func(*args) File "/usr/local/lib/python2.5/urllib2.py", line 506, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 400: Bad Request 'SERVER_SOFTWARE': 'Apache/2.2.12 (Unix) mod_wsgi/2.5 Python/2.5.4', </code></pre> <p>context_processors.py</p> <pre><code>from datetime import datetime from django.conf import settings from django.core.cache import cache import twitter from django.template import Library, Node, TemplateSyntaxError def latest_tweet( request ): tweet = cache.get( 'tweet' ) if tweet: return {"tweet": tweet} try: tweet = twitter.Api().GetUserTimeline( settings.TWITTER_USER )[0] tweet.date = datetime.strptime( tweet.created_at, "%a %b %d %H:%M:%S +0000 %Y" ) cache.set( 'tweet', tweet, settings.TWITTER_TIMEOUT ) except (RuntimeError, TypeError, NameError): pass return {"tweet": tweet} </code></pre> <p>THANK YOU!!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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