Я новичок в Django и Python.Вопросы по Django: RequestContext?
Когда я перемещаю свой код из своего локального блока разработчиков на свой сайт в Webfaction, он, похоже, нарушает мой код. Если я удалю (context_instance = RequestContext (запрос)) из моего основного приложения views.py, похоже, проблема устранена. Если позже я верну его, то все будет хорошо.
return render_to_response('template.html', {"var": var},**context_instance=RequestContext(request)**)
электронной почты Ошибка от хостинга:
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}
СПАСИБО !!
Вы можете оставлять свои настройки? – czarchaic