forked from onepercentclub/bluebottle
/
views.py
48 lines (33 loc) · 1.16 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import logging
logger = logging.getLogger(__name__)
from django.template import RequestContext, Context, loader
from django.http import HttpResponseServerError
from django.views.generic import TemplateView
from bluebottle.clients import properties
def handler500(request, template_name='500.html'):
"""
500 error handler which tries to use a RequestContext - unless an error
is raised, in which a normal Context is used with just the request
available.
Templates: `500.html`
Context: None
"""
# Try returning using a RequestContext
try:
context = RequestContext(request)
except:
logger.warn('Error getting RequestContext for ServerError page.')
context = Context({'request': request})
t = loader.get_template(
'500.html') # You need to create a 500.html template.
return HttpResponseServerError(t.render(context))
class HomeView(TemplateView):
"""
Home view for the site.
"""
template_name = 'base.html'
def get_context_data(self, **kwargs):
""" Add some extra context. """
context = {}
context['tenant_properties'] = properties
return context