Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 513961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:28:30+00:00 2026-05-13T07:28:30+00:00

I’m new to Django and Python. When I move my code from my local

  • 0

I’m new to Django and Python.

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 (context_instance=RequestContext(request)) from my main application views.py it seems to fix the problem. If later I put the line back in it works fine.

return render_to_response('template.html', {"var": var},**context_instance=RequestContext(request)**)

Error email from webhost:

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',

context_processors.py

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}

THANK YOU!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:28:31+00:00Added an answer on May 13, 2026 at 7:28 am

    It’s not RequestContext – context only triggers tweeter lookup which actually fails. If you put the line back in it works? That could only mean that your twitter lookup problem is inconsistent, as is possible with any HTTP lookups, so you should take care of possible network problems by also handling IOError (which is a parent of HTTPError and URLError which are thrown by urllib2).

    try:
        tweet = twitter.Api().GetUserTimeline( settings.TWITTER_USER )[0]
    except IOError, e:
        logging.error(e) #or just print, dont know how you log
    

    Analyze exactly how and when it fails and try to find the problem. Looking at the actual URL which urllib2 tries to access may help, too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 281k
  • Answers 281k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You have to create an culture in which sharing is… May 13, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer I suspect the localhost:1794 would be causing the issue -… May 13, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer I would assume http://icedtea.classpath.org/bugzilla/ given it's an icedtea package. May 13, 2026 at 3:54 pm

Related Questions

I want use html5's new tag to play a wav file (currently only supported
I've got a string that has curly quotes in it. I'd like to replace
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.