I'm new to django context processors. I wanted to create something which would give me famous quotes in every page of my blog app. When I deployed it to Heroku it started giving errors few minutes after its launching. These errors were :
could not fork new process for connection: Cannot allocate memory
SSL SYSCALL error: EOF detected
FATAL: out of memory
DETAIL: Failed on request of size 112.
Then the app restarts - back to normal. I could generate the same with javascript but still I wanted to do it with a context processor.
Is it advisable to create a context processor like one given below ?
from blog.models import Post
from random import randrange
def recent_posts(request):
u = Post.objects.all()[:5]
return {
'recent_posts': u
}
def quotes(request):
var = randrange(3)
quotes = {
'0' : "Quote 1",
'1' : "Quote 2",
'2' : "Quote 3",
}
quoted_by = {
'0' : "Person 1",
'1' : "Person 2",
'2' : "Person 3",
}
return {
'quotes': quotes[str(var)],
'quoted_by': quoted_by[str(var)]
}