def custom_404(request): """Custom 404 error handler.""" featured_rep = utils.latest_object_or_none(FeaturedRep) t = loader.get_template('404.html') return http.HttpResponseNotFound( t.render(RequestContext(request, {'request_path': request.path, 'featuredrep': featured_rep})))
def custom_404(request): """Custom 404 error handler.""" featured_rep = utils.latest_object_or_none(FeaturedRep) t = loader.get_template('404.html') return http.HttpResponseNotFound( t.render( RequestContext(request, { 'request_path': request.path, 'featuredrep': featured_rep })))
def main(request): """Main page of the website.""" featured_rep = utils.latest_object_or_none(FeaturedRep) if featured_rep: avatar_url = featured_rep.user.userprofile.get_avatar_url(80) else: avatar_url = None return render(request, 'main.html', {'featuredrep': featured_rep, 'avatar_url': avatar_url, 'next_url': reverse('dashboard')})
def custom_404(request): """Custom 404 error handler.""" featured_rep = utils.latest_object_or_none(FeaturedRep) if featured_rep: avatar_url = featured_rep.user.userprofile.get_avatar_url(80) else: avatar_url = None t = loader.get_template('404.html') return http.HttpResponseNotFound( t.render(RequestContext(request, {'request_path': request.path, 'featuredrep': featured_rep, 'avatar_url': avatar_url})))
def main(request): """Main page of the website.""" featured_rep = utils.latest_object_or_none(FeaturedRep) planet_feed = cache.get('planet') if not planet_feed: try: planet_feed = requests.get(settings.PLANET_URL, timeout=settings.PLANET_MAX_TIMEOUT).text except (requests.exceptions.Timeout, requests.exceptions.ConnectionError): planet_feed = '' else: cache.set('planet', planet_feed, 60 * 60 * 8) results = feedparser.parse(planet_feed).entries[:3] return render(request, 'main.jinja', {'featuredrep': featured_rep, 'planet_entries': results})
def main(request): """Main page of the website.""" featured_rep = utils.latest_object_or_none(FeaturedRep) planet_feed = cache.get('planet') if not planet_feed: try: planet_feed = requests.get( settings.PLANET_URL, timeout=settings.PLANET_MAX_TIMEOUT).text except (requests.exceptions.Timeout, requests.exceptions.ConnectionError): planet_feed = '' else: cache.set('planet', planet_feed, 60 * 60 * 8) results = feedparser.parse(planet_feed).entries[:3] return render(request, 'main.jinja', { 'featuredrep': featured_rep, 'planet_entries': results })
def main(request): """Main page of the website.""" featured_rep = utils.latest_object_or_none(FeaturedRep) return render(request, 'main.html', {'featuredrep': featured_rep})
def custom_404(request): """Custom 404 error handler.""" featured_rep = utils.latest_object_or_none(FeaturedRep) return http.HttpResponseNotFound( render(request, '404.html', {'featuredrep': featured_rep}))
def main(request): """Main page of the website.""" featured_rep = utils.latest_object_or_none(FeaturedRep) return render(request, 'main.html', {'featuredrep': featured_rep, 'next_url': reverse('dashboard')})
def custom_404(request): """Custom 404 error handler.""" featured_rep = utils.latest_object_or_none(FeaturedRep) return http.HttpResponseNotFound(render(request, '404.html', {'featuredrep': featured_rep}))