So, this is quite weird to me. I wrote an app that worked fine on Django 1., and I had way too much fun trying to update it to work with Django 4.1 - and it still doesn’t work.
I’m getting the following error (which I have NOT found anywhere using DuckDuckGo OR google!):
File "/usr/local/lib/python3.6/dist-packages/django/template/backends/django.py", line 59, in render
context = make_context(context, request, autoescape=self.backend.engine.autoescape)
File "/usr/local/lib/python3.6/dist-packages/django/template/context.py", line 268, in make_context
raise TypeError('context must be a dict rather than %s.' % context.__class__.__name__)
TypeError: context must be a dict rather than RequestContext.
[17/Sep/2022 13:08:43] "GET /home HTTP/1.1" 500 75180
Here’s (parts of) the code:
from django.http import HttpResponse, HttpResponseRedirect
from lunchpolls.models import *
from django.template import Context, loader, RequestContext, Template
...lots of code...
def home_processing(request,countvote):
...lots more code...
t = loader.get_template("home.html")
#t = Template("home.html")
c = RequestContext(request, { 'user_logged_in':user_logged_in,
'user_is_admin':user_is_admin,
'message':message,
'sortdir':sortdir,
'restaurantlist':restaurantlist,
'vote1':vote1,'vote2':vote2,
'sortby':str(sortfield),
'groupname':user_group_name,
'group_message':gmsg,
})
c.update(csrf(request))
return HttpResponse(t.render(c),request)
If I uncomment the Template line, the t.render(c) does not fail (and, of course, all I get is ‘home.html’ in my web browser - not the goal here! )
I’ve spent a pretty good amount of time trying to figure out why it appears that get_template does not return the thing that render requires, even reading through (well, ok, skimming through) ALL the release notes from 2.0 to 4.1 (or maybe 4.2, its all a blur now).
I’m out of ideas. Help!